Skip to content

Commit cc1b9ee

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix infinite recursion in property hook getter in opcache preloaded trait
2 parents d822e94 + 1e89e47 commit cc1b9ee

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

ext/opcache/ZendAccelerator.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4379,13 +4379,15 @@ static void preload_fix_trait_op_array(zend_op_array *op_array)
43794379
uint32_t fn_flags2 = op_array->fn_flags2;
43804380
zend_function *prototype = op_array->prototype;
43814381
HashTable *ht = op_array->static_variables;
4382+
const zend_property_info *prop_info = op_array->prop_info;
43824383
*op_array = *orig_op_array;
43834384
op_array->function_name = function_name;
43844385
op_array->scope = scope;
43854386
op_array->fn_flags = fn_flags;
43864387
op_array->fn_flags2 = fn_flags2;
43874388
op_array->prototype = prototype;
43884389
op_array->static_variables = ht;
4390+
op_array->prop_info = prop_info;
43894391
}
43904392

43914393
static void preload_fix_trait_methods(const zend_class_entry *ce)

ext/opcache/tests/gh21770.phpt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
GH-21770 (Infinite recursion in property hook getter in opcache preloaded trait)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
opcache.preload={PWD}/preload_gh21770.inc
8+
--EXTENSIONS--
9+
opcache
10+
--SKIPIF--
11+
<?php
12+
if (PHP_OS_FAMILY == 'Windows') die('skip Preloading is not supported on Windows');
13+
?>
14+
--FILE--
15+
<?php
16+
$b = new B();
17+
echo $b->a, "\n";
18+
19+
$c = new C();
20+
$c->x = 42;
21+
var_dump($c->x);
22+
?>
23+
--EXPECT--
24+
a
25+
int(42)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
trait A {
3+
public ?string $a = 'a' {
4+
get => $this->a;
5+
}
6+
}
7+
8+
trait X {
9+
public int $x = 0 {
10+
set(int $value) => $value;
11+
}
12+
}
13+
14+
class B {
15+
use A;
16+
}
17+
18+
class C {
19+
use X;
20+
}

0 commit comments

Comments
 (0)