Skip to content

Commit 14c42c6

Browse files
committed
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.
1 parent 6f24318 commit 14c42c6

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

ext/opcache/tests/preload.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ class TraitAliasTest {
5151
}
5252
}
5353

54+
// Create reference to a property declared in an internal parent class.
55+
class MyException extends Exception {
56+
public function __construct($message) {
57+
$this->message =& $message;
58+
}
59+
}
60+
5461
function get_anon() {
5562
return new class {};
5663
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Preloading of the property info table with internal parent
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
opcache.preload={PWD}/preload.inc
8+
--SKIPIF--
9+
<?php
10+
require_once('skipif.inc');
11+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
12+
?>
13+
--FILE--
14+
<?php
15+
$e = new MyException("foo");
16+
echo $e->getMessage(), "\n";
17+
?>
18+
--EXPECT--
19+
foo

ext/opcache/zend_persist.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,11 @@ static void zend_persist_class_entry(zval *zv)
914914

915915
for (i = 0; i < ce->default_properties_count; i++) {
916916
if (ce->properties_info_table[i]) {
917-
ce->properties_info_table[i] = zend_shared_alloc_get_xlat_entry(
917+
zend_property_info *prop_info = zend_shared_alloc_get_xlat_entry(
918918
ce->properties_info_table[i]);
919+
if (prop_info) {
920+
ce->properties_info_table[i] = prop_info;
921+
}
919922
}
920923
}
921924
}

0 commit comments

Comments
 (0)