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.

Built from https://develop.svn.wordpress.org/trunk@30561


git-svn-id: http://core.svn.wordpress.org/trunk@30550 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2014-11-25 05:01:23 +00:00
parent f3ba529c2f
commit a62fc4e4e5
2 changed files with 4 additions and 2 deletions

View File

@ -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;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.1-beta2-30560';
$wp_version = '4.1-beta2-30561';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.