X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjson%2FFormatJson.php;h=9ec3d96002fd3b2c2bcc7c362bb351d1d6ef3c35;hb=824ecd9b75bcbcbda0d9330656ea0f06ce288c3a;hp=1ab17a06f55e014c23b11aebd69b14dec39c2aff;hpb=f459a71f75941a83335d6d63ee12079a4b586793;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php index 1ab17a06f5..9ec3d96002 100644 --- a/includes/json/FormatJson.php +++ b/includes/json/FormatJson.php @@ -153,6 +153,16 @@ class FormatJson { * which returns more comprehensive result in case of an error, and has * more parsing options. * + * In PHP versions before 7.1, decoding a JSON string containing an empty key + * without passing $assoc as true results in a return object with a property + * named "_empty_" (because true empty properties were not supported pre-PHP-7.1). + * Instead, consider passing $assoc as true to return an associative array. + * + * But be aware that in all supported PHP versions, decoding an empty JSON object + * with $assoc = true returns an array, not an object, breaking round-trip consistency. + * + * See https://phabricator.wikimedia.org/T206411 for more details on these quirks. + * * @param string $value The JSON string being decoded * @param bool $assoc When true, returned objects will be converted into associative arrays. * @@ -271,7 +281,7 @@ class FormatJson { $lookAhead = ( $idx + 1 < $maxLen ) ? $str[$idx + 1] : ''; $lookBehind = ( $idx - 1 >= 0 ) ? $str[$idx - 1] : ''; if ( $inString ) { - continue; + break; } elseif ( !$inComment && ( $lookAhead === '/' || $lookAhead === '*' )