Files
php-src/ext/spl/tests/ArrayObject/gh_9707_unserialize.phpt
eafcd68369 zend_API: Verify property types in object_properties_load() (#23639)
* zend_API: Verify property types in `object_properties_load()`

Fixes php/php-src#9708.

* zend_API: Fix various issues in `object_properties_load()`

Fixes Fixes php/php-src#9707.

Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>

* NEWS

* random: Remove now-obsolete manual `$engine` type check in `Randomizer::__unserialize()`

* zend_API: Make `object_properties_load()` use `strict_types=1`

This is consistent with regular unserialization, which also performs strict
type checking.

Co-authored-by: Gina Peter Banyard <girgias@php.net>

* Block creation of readonly reference properties

Co-authored-by: Arnaud Le Blanc <365207+arnaud-lb@users.noreply.github.com>

---------

Co-authored-by: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Co-authored-by: Gina Peter Banyard <girgias@php.net>
Co-authored-by: Arnaud Le Blanc <365207+arnaud-lb@users.noreply.github.com>
2026-09-15 20:09:44 +02:00

42 lines
631 B
PHP

--TEST--
GH-9707: object_properties_load crashes in debug mode when unserializing references to typed properties in php 8.1+
--FILE--
<?php
class Foo extends ArrayObject {
public int $a = 0;
public int $b = 0;
}
$f = new Foo();
$r = &$f->a;
$f->b = &$r;
$f->b = 1;
var_dump($unserialized = unserialize(serialize($f)));
$unserialized->b = 2;
var_dump($unserialized);
?>
--EXPECTF--
object(Foo)#%d (3) {
["a"]=>
&int(1)
["b"]=>
&int(1)
["storage":"ArrayObject":private]=>
array(0) {
}
}
object(Foo)#%d (3) {
["a"]=>
&int(2)
["b"]=>
&int(2)
["storage":"ArrayObject":private]=>
array(0) {
}
}