[php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6
| From: | Arnaud Le Blanc | Date: | Tue, 17 Nov 2026 16:44:02 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143770@lists.php.net to get a copy of this message | ||
Author: Arnaud Le Blanc (arnaud-lb)
Date: 2026-11-17T17:42:37+01:00
Commit: https://github.com/php/php-src/commit/d6ff86a581e5e4465e497ef419c3144028024d17
Raw diff: https://github.com/php/php-src/commit/d6ff86a581e5e4465e497ef419c3144028024d17.diff
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
Fix object_properties_load() with integer keys (#25495)
Changed paths:
A ext/spl/tests/SplObjectStorage/SplObjectStorage_unserialize_int_property_keys.phpt
M NEWS
M Zend/zend_API.c
M ext/gmp/tests/gmp_dynamic_property.phpt
Diff:
diff --git a/NEWS b/NEWS
index 84e70e056c1a..9b52776e7b01 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,9 @@ PHP NEWS
. Fixed AST export of by-reference property hooks. (Jorg Sowa)
. Fixed AST export of property hook parameter lists and attributes.
(Jorg Sowa)
+ . Fixed object_properties_load() adding integer keys to property tables, which
+ made the properties unreadable and clone hit an assertion.
+ (Nicolas Grekas)
- Curl:
. Fixed curl_reset() retaining CURLOPT_PRIVATE after reset. (lacatoire)
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 4dba7fa25b07..55aa6ae84977 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -1858,7 +1858,10 @@ ZEND_API void object_properties_load(zend_object *object, const HashTable
*prope
object->ce->name, h);
}
- prop = zend_hash_index_update(zend_std_get_properties_ex(object), h, prop);
+ /* Property tables only have string keys */
+ zend_string *name = zend_long_to_str(h);
+ prop = zend_hash_update(zend_std_get_properties_ex(object), name, prop);
+ zend_string_release_ex(name, false);
zval_add_ref(prop);
}
} ZEND_HASH_FOREACH_END();
diff --git a/ext/gmp/tests/gmp_dynamic_property.phpt b/ext/gmp/tests/gmp_dynamic_property.phpt
index ff3d4ac94e01..dd442043a27f 100644
--- a/ext/gmp/tests/gmp_dynamic_property.phpt
+++ b/ext/gmp/tests/gmp_dynamic_property.phpt
@@ -17,7 +17,7 @@ Deprecated: Creation of dynamic property GMP::$1 is deprecated in %s on line %d
Deprecated: Creation of dynamic property GMP::$1 is deprecated in %s on line %d
object(GMP)#%d (%d) {
- [1]=>
+ ["1"]=>
int(123)
["num"]=>
string(1) "0"
diff --git a/ext/spl/tests/SplObjectStorage/SplObjectStorage_unserialize_int_property_keys.phpt
b/ext/spl/tests/SplObjectStorage/SplObjectStorage_unserialize_int_property_keys.phpt
new file mode 100644
index 000000000000..deb59b15a457
--- /dev/null
+++ b/ext/spl/tests/SplObjectStorage/SplObjectStorage_unserialize_int_property_keys.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Integer keys in the properties that internal classes load when unserialized
+--FILE--
+<?php
+
+#[AllowDynamicProperties]
+class Storage extends SplObjectStorage {}
+
+$storage =
unserialize('O:7:"Storage":2:{i:0;a:0:{}i:1;a:1:{i:7;s:1:"y";}}');
+var_dump($storage->{7});
+var_dump(clone $storage);
+
+?>
+--EXPECT--
+string(1) "y"
+object(Storage)#2 (2) {
+ ["7"]=>
+ string(1) "y"
+ ["storage":"SplObjectStorage":private]=>
+ array(0) {
+ }
+}