]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-5.4' into PHP-5.5
authorStanislav Malyshev <stas@php.net>
Mon, 14 Apr 2014 01:54:54 +0000 (18:54 -0700)
committerStanislav Malyshev <stas@php.net>
Mon, 14 Apr 2014 01:55:28 +0000 (18:55 -0700)
* PHP-5.4:
  Fix #66021 (Blank line inside empty array/object)

1  2 
NEWS
ext/json/json.c

diff --cc NEWS
index 3de1f3d330fbf8ed85dd84349663becc8fba2170,d04e961a311ce003c84e646523032d23c598d1a4..f571b560eef8e542a9761323bd7e10f1405a8fe3
--- 1/NEWS
--- 2/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 b0191c38f5582b26969f8da08ee834348db996b1,b3240e1b4bf8190200928e7b9cadfece08fcefa9..6b66dce3df362a8c861c08cac0d7c960d8424ca1
@@@ -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, ']');