From bcc87ba68ede7b90cd544ec0911bdbe5d844aa2a Mon Sep 17 00:00:00 2001 From: johannes Date: Thu, 5 Jul 2012 00:55:47 +0200 Subject: [PATCH] Revert change 3f3ad30c50: There shouldn't be new features in 5.3, especially not if they aren't in 5.4, too. --- ext/json/json.c | 11 ++++------- ext/json/php_json.h | 1 - ext/json/tests/bug43941.phpt | 21 +++++++++++++++++++++ ext/json/tests/bug54058.phpt | 7 ------- ext/json/tests/bug61537.phpt | 30 ------------------------------ 5 files changed, 25 insertions(+), 45 deletions(-) create mode 100644 ext/json/tests/bug43941.phpt delete mode 100644 ext/json/tests/bug61537.phpt diff --git a/ext/json/json.c b/ext/json/json.c index ce2cf43fcc..5b62c2feea 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -73,7 +73,6 @@ static PHP_MINIT_FUNCTION(json) REGISTER_LONG_CONSTANT("JSON_HEX_QUOT", PHP_JSON_HEX_QUOT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_FORCE_OBJECT", PHP_JSON_FORCE_OBJECT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_NUMERIC_CHECK", PHP_JSON_NUMERIC_CHECK, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("JSON_PARTIAL_OUTPUT_ON_ERROR", PHP_JSON_PARTIAL_OUTPUT_ON_ERROR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_ERROR_NONE", PHP_JSON_ERROR_NONE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("JSON_ERROR_DEPTH", PHP_JSON_ERROR_DEPTH, CONST_CS | CONST_PERSISTENT); @@ -321,7 +320,9 @@ static void json_escape_string(smart_str *buf, char *s, int len, int options TSR } if (len < 0) { JSON_G(error_code) = PHP_JSON_ERROR_UTF8; - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid UTF-8 sequence in argument"); + if (!PG(display_errors)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid UTF-8 sequence in argument"); + } smart_str_appendl(buf, "null", 4); } else { smart_str_appendl(buf, "\"\"", 2); @@ -570,11 +571,7 @@ static PHP_FUNCTION(json_encode) php_json_encode(&buf, parameter, options TSRMLS_CC); - if (JSON_G(error_code) != PHP_JSON_ERROR_NONE && options ^ PHP_JSON_PARTIAL_OUTPUT_ON_ERROR) { - ZVAL_FALSE(return_value); - } else { - ZVAL_STRINGL(return_value, buf.c, buf.len, 1); - } + ZVAL_STRINGL(return_value, buf.c, buf.len, 1); smart_str_free(&buf); } diff --git a/ext/json/php_json.h b/ext/json/php_json.h index 3cb4902e27..b104d4ca6a 100644 --- a/ext/json/php_json.h +++ b/ext/json/php_json.h @@ -56,7 +56,6 @@ PHP_JSON_API void php_json_decode(zval *return_value, char *str, int str_len, ze #define PHP_JSON_HEX_QUOT (1<<3) #define PHP_JSON_FORCE_OBJECT (1<<4) #define PHP_JSON_NUMERIC_CHECK (1<<5) -#define PHP_JSON_PARTIAL_OUTPUT_ON_ERROR (1<<9) #define PHP_JSON_OUTPUT_ARRAY 0 #define PHP_JSON_OUTPUT_OBJECT 1 diff --git a/ext/json/tests/bug43941.phpt b/ext/json/tests/bug43941.phpt new file mode 100644 index 0000000000..0f86d1dfad --- /dev/null +++ b/ext/json/tests/bug43941.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #43941 (json_encode() invalid UTF-8) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +string(5) ""abc"" +string(4) "null" +string(4) "null" +string(17) "[null,null,"abc"]" +Done + diff --git a/ext/json/tests/bug54058.phpt b/ext/json/tests/bug54058.phpt index 08c7f579ab..3b1136bdd9 100644 --- a/ext/json/tests/bug54058.phpt +++ b/ext/json/tests/bug54058.phpt @@ -29,14 +29,7 @@ json_encode($c); var_dump(json_last_error()); ?> --EXPECTF-- -Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d int(5) - -Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d int(5) - -Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d int(5) - -Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d int(5) diff --git a/ext/json/tests/bug61537.phpt b/ext/json/tests/bug61537.phpt deleted file mode 100644 index e2abdda66a..0000000000 --- a/ext/json/tests/bug61537.phpt +++ /dev/null @@ -1,30 +0,0 @@ ---TEST-- -Bug #61537 (json_encode() incorrectly truncates/discards information) ---SKIPIF-- - ---FILE-- - ---EXPECTF-- -Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d -bool(false) -int(5) - -Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d -string(4) "null" -int(5) - -Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d -bool(false) -int(5) - -Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d -string(4) "null" -int(5) -- 2.40.0