(Nikita)
. Fixed bug #72059 (?? is not allowed on constant expressions). (Bob, Marcio)
+- JSON:
+ . Fixed bug #72069 (Behavior \JsonSerializable different from json_encode).
+ (Laruence)
+
- OCI8:
. Fixed bug #71600 (oci_fetch_all segfaults when selecting more than eight
columns). (Tian Yang)
return;
}
- JSON_G(error_code) = 0;
+ JSON_G(error_code) = PHP_JSON_ERROR_NONE;
if (!str_len) {
JSON_G(error_code) = PHP_JSON_ERROR_SYNTAX;
zend_class_entry *ce = Z_OBJCE_P(val);
zval retval, fname;
HashTable* myht;
+ int origin_error_code;
if (Z_TYPE_P(val) == IS_ARRAY) {
myht = Z_ARRVAL_P(val);
return;
}
+
ZVAL_STRING(&fname, "jsonSerialize");
+ origin_error_code = JSON_G(error_code);
if (FAILURE == call_user_function_ex(EG(function_table), val, &fname, &retval, 0, NULL, 1, NULL) || Z_TYPE(retval) == IS_UNDEF) {
zend_throw_exception_ex(NULL, 0, "Failed calling %s::jsonSerialize()", ZSTR_VAL(ce->name));
smart_str_appendl(buf, "null", sizeof("null") - 1);
return;
}
+ JSON_G(error_code) = origin_error_code;
if (EG(exception)) {
/* Error already raised */
zval_ptr_dtor(&retval);
--- /dev/null
+--TEST--
+Bug #72069 (Behavior \JsonSerializable different from json_encode)
+--SKIPIF--
+<?php if (!extension_loaded("json")) print "skip"; ?>
+--FILE--
+<?php
+
+$result = json_encode(['end' => json_decode(null, true)]);
+var_dump($result);
+
+class A implements \JsonSerializable
+{
+ function jsonSerialize()
+ {
+ return ['end' => json_decode(null, true)];
+ }
+}
+$a = new A();
+$toJsonData = $a->jsonSerialize();
+$result = json_encode($a);
+var_dump($result);
+
+$result = json_encode($toJsonData);
+var_dump($result);
+?>
+--EXPECT--
+string(12) "{"end":null}"
+string(12) "{"end":null}"
+string(12) "{"end":null}"