Handle indirect zvals in SplFixedArray::__serialize

Closes GH-10925.
This commit is contained in:
Niels Dossche 2023-03-24 19:18:28 +01:00
parent 1f5d9534ae
commit e698938229
3 changed files with 5 additions and 3 deletions

2
NEWS
View file

@ -66,6 +66,8 @@ PHP NEWS
PHP 8.2.4). (nielsdos)
. Fixed bug GH-10844 (ArrayIterator allows modification of readonly props).
(ilutov)
. Fixed bug GH-10925 (Handle indirect zvals in SplFixedArray::__serialize).
(nielsdos)
- Standard:
. Fixed bug GH-10885 (stream_socket_server context leaks). (ilutov)

View file

@ -610,7 +610,7 @@ PHP_METHOD(SplFixedArray, __serialize)
/* members */
if (intern->std.properties) {
ZEND_HASH_FOREACH_STR_KEY_VAL(intern->std.properties, key, current) {
ZEND_HASH_FOREACH_STR_KEY_VAL_IND(intern->std.properties, key, current) {
/* The properties hash table can also contain the array elements if the properties table was already rebuilt.
* In this case we'd have a NULL key. We can't simply use the properties table in all cases because it's
* potentially out of sync (missing elements, or containing removed elements) and might need a rebuild. */

View file

@ -112,10 +112,10 @@ object(SplFixedArray)#1 (3) {
}
=================
Test with adding members
string(161) "O:15:"MySplFixedArray":5:{i:0;s:12:"test value 1";i:1;s:12:"test value 2";i:2;N;s:9:"my_string";i:0;s:19:"my_dynamic_property";s:25:"my_dynamic_property_value";}"
string(180) "O:15:"MySplFixedArray":5:{i:0;s:12:"test value 1";i:1;s:12:"test value 2";i:2;N;s:9:"my_string";s:15:"my_string_value";s:19:"my_dynamic_property";s:25:"my_dynamic_property_value";}"
object(MySplFixedArray)#1 (5) {
["my_string"]=>
int(0)
string(15) "my_string_value"
["my_dynamic_property"]=>
string(25) "my_dynamic_property_value"
[0]=>