Skip to content

Commit

Permalink
Fix persisting property info table with internal parent
Browse files Browse the repository at this point in the history
If the property info comes from an internal parent, we won't have
an xlat entry for it. Leave it alone in that case.
  • Loading branch information
nikic committed Nov 3, 2020
1 parent 6f24318 commit 14c42c6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ext/opcache/tests/preload.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
}
Expand Down
19 changes: 19 additions & 0 deletions ext/opcache/tests/preload_prop_info_table.phpt
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion ext/opcache/zend_persist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit 14c42c6

Please sign in to comment.