-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix get_object_vars() for non-hooked props in hooked prop iter
Very confusingly, the zend_hash_update_ind() variant unwraps indirects, rather than creating them. Don't use _zend_hash_append_ind() because the property might already exist. Fixes GH-16725
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
GH-16725: Incorrect access check for non-hooked props in hooked object iterator | ||
--FILE-- | ||
<?php | ||
|
||
class C implements JsonSerializable | ||
{ | ||
private string $prop1 { get => 'bar'; } | ||
|
||
public function __construct( | ||
private string $prop2, | ||
) {} | ||
|
||
public function jsonSerialize(): mixed { | ||
return get_object_vars($this); | ||
} | ||
} | ||
|
||
$obj = new C('foo'); | ||
var_dump(get_object_vars($obj)); | ||
echo json_encode($obj); | ||
|
||
?> | ||
--EXPECT-- | ||
array(0) { | ||
} | ||
{"prop1":"bar","prop2":"foo"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters