Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 32 additions & 0 deletions Zend/tests/lazy_objects/gh23842.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--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--
<?php

class Currency {
public const string EUR = 'EUR';
}

class Product {
public string $currency = Currency::EUR;
}

$reflector = new ReflectionClass(Product::class);
$product = $reflector->newLazyGhost(function () {
throw new \Exception('initializer');
});
$reflector->getProperty('currency')->skipLazyInitialization($product);

var_dump($product->currency);

?>
--EXPECT--
string(3) "EUR"
2 changes: 1 addition & 1 deletion ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Loading