Skip to content

Commit 068a02d

Browse files
committed
Fix another round of review comments
1 parent ac67ff9 commit 068a02d

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

Zend/zend_API.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,11 +1630,11 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties)
16301630
} else {
16311631
if (UNEXPECTED(object->ce->ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES)) {
16321632
zend_throw_error(NULL, "Cannot create dynamic property %s::$%s",
1633-
ZSTR_VAL(object->ce->name), zend_get_unmangled_property_name(key));
1633+
ZSTR_VAL(object->ce->name), property_info != ZEND_WRONG_PROPERTY_INFO ? zend_get_unmangled_property_name(key): "");
16341634
return;
16351635
} else if (!(object->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) {
16361636
zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated",
1637-
ZSTR_VAL(object->ce->name), zend_get_unmangled_property_name(key));
1637+
ZSTR_VAL(object->ce->name), property_info != ZEND_WRONG_PROPERTY_INFO ? zend_get_unmangled_property_name(key): "");
16381638
}
16391639

16401640
if (!object->properties) {
@@ -1645,12 +1645,11 @@ ZEND_API void object_properties_load(zend_object *object, HashTable *properties)
16451645
}
16461646
} else {
16471647
if (UNEXPECTED(object->ce->ce_flags & ZEND_ACC_NO_DYNAMIC_PROPERTIES)) {
1648-
zend_throw_error(NULL, "Cannot create dynamic property %s::$%s",
1649-
ZSTR_VAL(object->ce->name), zend_get_unmangled_property_name(key));
1648+
zend_throw_error(NULL, "Cannot create dynamic property %s::$" ZEND_LONG_FMT, ZSTR_VAL(object->ce->name), h);
16501649
return;
16511650
} else if (!(object->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) {
1652-
zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated",
1653-
ZSTR_VAL(object->ce->name), zend_get_unmangled_property_name(key));
1651+
zend_error(E_DEPRECATED, "Creation of dynamic property %s::$" ZEND_LONG_FMT " is deprecated",
1652+
ZSTR_VAL(object->ce->name), h);
16541653
}
16551654

16561655
if (!object->properties) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-9186 Dynamic property unserialization should trigger a deprecated notice
3+
--EXTENSIONS--
4+
gmp
5+
--FILE--
6+
<?php
7+
8+
$g = new GMP();
9+
$g->{1} = 123;
10+
11+
$serialized = serialize($g);
12+
var_dump(unserialize($serialized));
13+
14+
?>
15+
--EXPECTF--
16+
Deprecated: Creation of dynamic property GMP::$1 is deprecated in %s on line %d
17+
18+
Deprecated: Creation of dynamic property GMP::$1 is deprecated in %s on line %d
19+
object(GMP)#%d (%d) {
20+
[1]=>
21+
int(123)
22+
["num"]=>
23+
string(1) "0"
24+
}

ext/random/randomizer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ PHP_METHOD(Random_Randomizer, __unserialize)
279279
}
280280
object_properties_load(&randomizer->std, Z_ARRVAL_P(members_zv));
281281
if (EG(exception)) {
282+
zend_throw_exception(NULL, "Invalid serialization data for Random\\Randomizer object", 0);
282283
RETURN_THROWS();
283284
}
284285

ext/standard/var_unserializer.re

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ declared_property:
645645
} else if (!(obj->ce->ce_flags & ZEND_ACC_ALLOW_DYNAMIC_PROPERTIES)) {
646646
zend_error(E_DEPRECATED, "Creation of dynamic property %s::$%s is deprecated",
647647
ZSTR_VAL(obj->ce->name), zend_get_unmangled_property_name(Z_STR_P(&key)));
648+
if (EG(exception)) {
649+
goto failure;
650+
}
648651
}
649652

650653
int ret = is_property_visibility_changed(obj->ce, &key);

0 commit comments

Comments
 (0)