Open tatref opened 4 years ago
The function producing the error is:
return json_encode($arrRet);
Possible fixes:
1) PHP 7.2 introduces the following flags for json_encode
: JSON_INVALID_UTF8_IGNORE
, JSON_INVALID_UTF8_SUBSTITUTE
2) Use iconv
prior to json_encode
(I know nothing about PHP...):
array_walk_recursive($arrRet, function(&$value) {
$new_value = iconv('UTF-8', 'UTF-8//IGNORE', $value);
if ("$new_value" !== "$value") {
error_log("Corrected UTF-8 string: $value => $new_value");
$value = $new_value;
}
});
return json_encode($arrRet);
For the moment, I'm testing the iconv code provided
3) make sure the data is properly encoding when making the requests from the DB
4) if no proper fix is possible, at least show the item producing the error
Hi,
From time to time, I hit the following error:
I think that some check is returning garbage data from time to time, but I don't known how to identify which one. I already spent some time making requests in the database without any success.
Any idea is very welcome!