com php-src: Fix persisting property info table with internal parent: ext/opcache/tests/preload.inc ext/opcache/tests/preload_prop _info_table.phpt
ext/opcache/zend_persist.c
| From: | Nikita Popov | Date: | Tue, 03 Nov 2020 10:30:44 +0000 |
| Subject: | com php-src: Fix persisting property info table with internal parent: ext/opcache/tests/preload.inc ext/opcache/tests/preload_prop _info_table.phpt ext/opcache/zend_persist.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-114045@lists.php.net to get a copy of this message | ||
Commit: 14c42c69611a6c3e2f077ce6b389b1000edd2995
Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 3 Nov 2020 11:26:52 +0100
Parents: 6f2431860b309df87d8a4d977b0a0bfb05182855
Branches: PHP-8.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=14c42c69611a6c3e2f077ce6b389b1000edd2995
Log:
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.
Changed paths:
M ext/opcache/tests/preload.inc
A ext/opcache/tests/preload_prop_info_table.phpt
M ext/opcache/zend_persist.c
Diff:
diff --git a/ext/opcache/tests/preload.inc b/ext/opcache/tests/preload.inc
index 0ef3b4f56e3..13c9db12835 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 00000000000..51c798409cb
--- /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--
+<?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
diff --git a/ext/opcache/zend_persist.c b/ext/opcache/zend_persist.c
index 415aa76093f..77d67851b45 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;
+ }
}
}
}