mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Fix bug #71835 (json_encode sometimes incorrectly detects recursion with JsonSerializable)
This commit is contained in:
parent
a175aa9dca
commit
7e069daa89
3 changed files with 22 additions and 1 deletions
4
NEWS
4
NEWS
|
@ -12,6 +12,10 @@ PHP NEWS
|
||||||
. Fixed bug #69659 (ArrayAccess, isset() and the offsetExists method).
|
. Fixed bug #69659 (ArrayAccess, isset() and the offsetExists method).
|
||||||
(Nikita)
|
(Nikita)
|
||||||
|
|
||||||
|
- JSON:
|
||||||
|
. Fixed bug #71835 (json_encode sometimes incorrectly detects recursion
|
||||||
|
with JsonSerializable). (Jakub Zelenka)
|
||||||
|
|
||||||
- ODBC:
|
- ODBC:
|
||||||
. Fixed bug #63171 (Script hangs after max_execution_time). (Remi)
|
. Fixed bug #63171 (Script hangs after max_execution_time). (Remi)
|
||||||
|
|
||||||
|
|
|
@ -1183,7 +1183,7 @@ ZEND_FUNCTION(get_object_vars)
|
||||||
|
|
||||||
zobj = Z_OBJ_P(obj);
|
zobj = Z_OBJ_P(obj);
|
||||||
|
|
||||||
if (!zobj->ce->default_properties_count && properties == zobj->properties) {
|
if (!zobj->ce->default_properties_count && properties == zobj->properties && !ZEND_HASH_GET_APPLY_COUNT(properties)) {
|
||||||
/* fast copy */
|
/* fast copy */
|
||||||
if (EXPECTED(zobj->handlers == &std_object_handlers)) {
|
if (EXPECTED(zobj->handlers == &std_object_handlers)) {
|
||||||
if (EXPECTED(!(GC_FLAGS(properties) & IS_ARRAY_IMMUTABLE))) {
|
if (EXPECTED(!(GC_FLAGS(properties) & IS_ARRAY_IMMUTABLE))) {
|
||||||
|
|
17
ext/json/tests/bug71835.phpt
Normal file
17
ext/json/tests/bug71835.phpt
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #71835 (json_encode sometimes incorrectly detects recursion with JsonSerializable)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php if (!extension_loaded("json")) print "skip"; ?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
class SomeClass implements JsonSerializable {
|
||||||
|
public function jsonSerialize() {
|
||||||
|
return [get_object_vars($this)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$class = new SomeClass;
|
||||||
|
$arr = [$class];
|
||||||
|
var_dump(json_encode($arr));
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
string(6) "[[[]]]"
|
Loading…
Add table
Add a link
Reference in a new issue