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.
This commit is contained in:
Nikita Popov 2020-11-03 11:26:52 +01:00
parent 6f2431860b
commit 14c42c6961
3 changed files with 30 additions and 1 deletions

View File

@ -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 {};
}

View File

@ -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--
<?php
require_once('skipif.inc');
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
?>
--FILE--
<?php
$e = new MyException("foo");
echo $e->getMessage(), "\n";
?>
--EXPECT--
foo

View File

@ -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;
}
}
}
}