From a62fc4e4e57f44058aef38edbcc7ee2b2d02f8b7 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 25 Nov 2014 05:01:23 +0000 Subject: [PATCH] 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 --- wp-includes/functions.php | 4 +++- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 0fb2117835..9f229291a7 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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; } diff --git a/wp-includes/version.php b/wp-includes/version.php index eedce7f17b..d178f218cd 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.