Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -4290,12 +4290,14 @@ static void preload_fix_trait_op_array(zend_op_array *op_array)
uint32_t fn_flags = op_array->fn_flags;
zend_function *prototype = op_array->prototype;
HashTable *ht = op_array->static_variables;
const zend_property_info *prop_info = op_array->prop_info;
*op_array = *orig_op_array;
op_array->function_name = function_name;
op_array->scope = scope;
op_array->fn_flags = fn_flags;
op_array->prototype = prototype;
op_array->static_variables = ht;
op_array->prop_info = prop_info;
}

static void preload_fix_trait_methods(zend_class_entry *ce)
Expand Down
25 changes: 25 additions & 0 deletions ext/opcache/tests/gh21770.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
GH-21770 (Infinite recursion in property hook getter in opcache preloaded trait)
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.preload={PWD}/preload_gh21770.inc
--EXTENSIONS--
opcache
--SKIPIF--
<?php
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
?>
--FILE--
<?php
$b = new B();
echo $b->a, "\n";

$c = new C();
$c->x = 42;
var_dump($c->x);
?>
--EXPECT--
a
int(42)
20 changes: 20 additions & 0 deletions ext/opcache/tests/preload_gh21770.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
trait A {
public ?string $a = 'a' {
get => $this->a;
}
}

trait X {
public int $x = 0 {
set(int $value) => $this->x = $value;
}
}

class B {
use A;
}

class C {
use X;
}
Loading