mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
When json_encode() returns a JSON string containing 'null' in PHP 5.4 or earlier, wp_json_encode() will now sanity check the data, as older versions of PHP failed to encode non UTF-8 characters correctly, instead returning 'null'.
Fixes #30471. git-svn-id: https://develop.svn.wordpress.org/trunk@30561 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2662,7 +2662,9 @@ function wp_json_encode( $data, $options = 0, $depth = 512 ) {
|
||||
$json = call_user_func_array( 'json_encode', $args );
|
||||
|
||||
// If json_encode() was successful, no need to do more sanity checking.
|
||||
if ( false !== $json ) {
|
||||
// ... unless we're in an old version of PHP, and json_encode() returned
|
||||
// a string containing 'null'. Then we need to do more sanity checking.
|
||||
if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) ) {
|
||||
return $json;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user