From: Stanislav Malyshev Date: Mon, 14 Apr 2014 01:54:54 +0000 (-0700) Subject: Merge branch 'PHP-5.4' into PHP-5.5 X-Git-Tag: php-5.5.12RC1~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9bba219c75b0fa82846bc2fa260888cdc97ac6e6;p=php Merge branch 'PHP-5.4' into PHP-5.5 * PHP-5.4: Fix #66021 (Blank line inside empty array/object) --- 9bba219c75b0fa82846bc2fa260888cdc97ac6e6 diff --cc NEWS index 3de1f3d330,d04e961a31..f571b560ee --- a/NEWS +++ b/NEWS @@@ -29,11 -29,7 +29,15 @@@ PH (Remi) - FPM: - . Fixed bug #66482 (unknown entry 'priority' in php-fpm.conf). + . Fixed bug #66482 (unknown entry 'priority' in php-fpm.conf). + ++- JSON: ++ . Fixed bug #66021 (Blank line inside empty array/object when ++ JSON_PRETTY_PRINT is set). (Kevin Israel) ++ +- mysqli: + . Fixed problem in mysqli_commit()/mysqli_rollback() with second parameter + (extra comma) and third parameters (lack of escaping). (Andrey) - SimpleXML: . Fixed bug #66084 (simplexml_load_string() mangles empty node name) diff --cc ext/json/json.c index b0191c38f5,b3240e1b4b..6b66dce3df --- a/ext/json/json.c +++ b/ext/json/json.c @@@ -343,12 -330,13 +341,16 @@@ static void json_encode_array(smart_st } } + if (JSON_G(encoder_depth) > JSON_G(encode_max_depth)) { + JSON_G(error_code) = PHP_JSON_ERROR_DEPTH; + } --JSON_G(encoder_depth); - json_pretty_print_char(buf, options, '\n' TSRMLS_CC); - json_pretty_print_indent(buf, options TSRMLS_CC); + + /* Only keep closing bracket on same line for empty arrays/objects */ + if (need_comma) { + json_pretty_print_char(buf, options, '\n' TSRMLS_CC); + json_pretty_print_indent(buf, options TSRMLS_CC); + } if (r == PHP_JSON_OUTPUT_ARRAY) { smart_str_appendc(buf, ']');