From ffe9d5bd027b033bbc00656aef5f6ae311a14a7f Mon Sep 17 00:00:00 2001 From: lazerg Date: Tue, 22 Sep 2026 16:21:45 +0500 Subject: [PATCH 1/2] Fix GH-23842: skipLazyInitialization() copies unresolved constant defaults --- NEWS | 4 ++++ Zend/tests/lazy_objects/gh23842.phpt | 29 ++++++++++++++++++++++++++++ ext/reflection/php_reflection.c | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 Zend/tests/lazy_objects/gh23842.phpt diff --git a/NEWS b/NEWS index a37bfa30e4bc..f17cbe9efd8d 100644 --- a/NEWS +++ b/NEWS @@ -64,6 +64,10 @@ PHP NEWS . Fixed a heap over-read in the interactive shell prompt when cli.prompt is set to an empty string. (Ilia Alshanetsky) +- Reflection: + . Fixed bug GH-23842 (ReflectionProperty::skipLazyInitialization() copies an + unresolved constant default with opcache). (Lazizbek Ergashev) + - Sockets: . Fixed socket_select() silently truncating sets larger than FD_SETSIZE on Windows. (David Carlier) diff --git a/Zend/tests/lazy_objects/gh23842.phpt b/Zend/tests/lazy_objects/gh23842.phpt new file mode 100644 index 000000000000..18ceea7e6ebf --- /dev/null +++ b/Zend/tests/lazy_objects/gh23842.phpt @@ -0,0 +1,29 @@ +--TEST-- +GH-23842: skipLazyInitialization() copies an unresolved constant default with opcache +--EXTENSIONS-- +opcache +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +--FILE-- +newLazyGhost(function () { + throw new \Exception('initializer'); +}); +$reflector->getProperty('currency')->skipLazyInitialization($product); + +var_dump($product->currency); + +?> +--EXPECT-- +string(3) "EUR" diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index c7b15c63a0c5..2c94a6e80d18 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -6461,7 +6461,7 @@ ZEND_METHOD(ReflectionProperty, skipLazyInitialization) RETURN_THROWS(); } - zval *src = &object->ce->default_properties_table[OBJ_PROP_TO_NUM(prop->offset)]; + zval *src = &CE_DEFAULT_PROPERTIES_TABLE(object->ce)[OBJ_PROP_TO_NUM(prop->offset)]; zval *dst = OBJ_PROP(object, prop->offset); if (!(Z_PROP_FLAG_P(dst) & IS_PROP_LAZY)) { From d6ce8bdd51f77fd341e6e2b939d38b91551f189e Mon Sep 17 00:00:00 2001 From: lazerg Date: Tue, 22 Sep 2026 16:29:45 +0500 Subject: [PATCH 2/2] Credit the reporter and pin opcache.file_cache_only in the GH-23842 test --- Zend/tests/lazy_objects/gh23842.phpt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Zend/tests/lazy_objects/gh23842.phpt b/Zend/tests/lazy_objects/gh23842.phpt index 18ceea7e6ebf..fe791dde685b 100644 --- a/Zend/tests/lazy_objects/gh23842.phpt +++ b/Zend/tests/lazy_objects/gh23842.phpt @@ -1,10 +1,13 @@ --TEST-- GH-23842: skipLazyInitialization() copies an unresolved constant default with opcache +--CREDITS-- +DirkTrunkstar --EXTENSIONS-- opcache --INI-- opcache.enable=1 opcache.enable_cli=1 +opcache.file_cache_only=0 --FILE--