Closed andrewandante closed 3 years ago
Would using multi-byte compatible functions (mb_substr
and mb_strlen
) do the job without potentially trying to encode the data several times in the loop?
Would using multi-byte compatible functions (
mb_substr
andmb_strlen
) do the job without potentially trying to encode the data several times in the loop?
Hmm fair point, that seems to work as well - will try on a full reindex and confirm
Yep much cleaner and has the same effect - nice spot @michalkleiner
Fixes an error I was seeing a lot:
It was coming from truncating content that was in Thai (amongst other languages) that would have characters cut through the middle, making them invalid UTF-8 and causing the
json_encode()
to fail when Guzzle was trying to compile the body to fire through to Elastic.This PR checks that the
string
isjson_encode()
-able and nudges the truncate one char each loop until it is.