From: Nikita Popov Date: Tue, 3 Nov 2020 10:26:52 +0000 (+0100) Subject: Fix persisting property info table with internal parent X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14c42c69611a6c3e2f077ce6b389b1000edd2995;p=php Fix persisting property info table with internal parent If the property info comes from an internal parent, we won't have an xlat entry for it. Leave it alone in that case. --- diff --git a/ext/opcache/tests/preload.inc b/ext/opcache/tests/preload.inc index 0ef3b4f56e..13c9db1283 100644 --- a/ext/opcache/tests/preload.inc +++ b/ext/opcache/tests/preload.inc @@ -51,6 +51,13 @@ class TraitAliasTest { } } +// Create reference to a property declared in an internal parent class. +class MyException extends Exception { + public function __construct($message) { + $this->message =& $message; + } +} + function get_anon() { return new class {}; } diff --git a/ext/opcache/tests/preload_prop_info_table.phpt b/ext/opcache/tests/preload_prop_info_table.phpt new file mode 100644 index 0000000000..51c798409c --- /dev/null +++ b/ext/opcache/tests/preload_prop_info_table.phpt @@ -0,0 +1,19 @@ +--TEST-- +Preloading of the property info table with internal parent +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +opcache.preload={PWD}/preload.inc +--SKIPIF-- + +--FILE-- +getMessage(), "\n"; +?> +--EXPECT-- +foo diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c index 415aa76093..77d67851b4 100644 --- a/ext/opcache/zend_persist.c +++ b/ext/opcache/zend_persist.c @@ -914,8 +914,11 @@ static void zend_persist_class_entry(zval *zv) for (i = 0; i < ce->default_properties_count; i++) { if (ce->properties_info_table[i]) { - ce->properties_info_table[i] = zend_shared_alloc_get_xlat_entry( + zend_property_info *prop_info = zend_shared_alloc_get_xlat_entry( ce->properties_info_table[i]); + if (prop_info) { + ce->properties_info_table[i] = prop_info; + } } } }