]> granicus.if.org Git - php/commitdiff
Fix persisting property info table with internal parent
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 3 Nov 2020 10:26:52 +0000 (11:26 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 3 Nov 2020 10:30:44 +0000 (11:30 +0100)
If the property info comes from an internal parent, we won't have
an xlat entry for it. Leave it alone in that case.

ext/opcache/tests/preload.inc
ext/opcache/tests/preload_prop_info_table.phpt [new file with mode: 0644]
ext/opcache/zend_persist.c

index 0ef3b4f56e3a7d9ab47b57d63c1d17d2ffb56886..13c9db128359524bf6e0dae425f230af4f17c594 100644 (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 {};
 }
diff --git a/ext/opcache/tests/preload_prop_info_table.phpt b/ext/opcache/tests/preload_prop_info_table.phpt
new file mode 100644 (file)
index 0000000..51c7984
--- /dev/null
@@ -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
index 415aa76093f7ea383708269d1febd242aeb74002..77d67851b45f8e74288ed113465bb3856f057f00 100644 (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;
+                                       }
                                }
                        }
                }