Skip to content

Commit 1e89e47

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

4 files changed

Lines changed: 49 additions & 0 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ PHP NEWS
1818
iliaal)
1919
. Fixed bug GH-22443 (Tracing JIT SIGSEGV on megamorphic dynamic calls from
2020
an undereferenced run_time_cache map_ptr offset). (iliaal)
21+
. Fixed bug GH-21770 (Infinite recursion in property hook getter in opcache
22+
preloaded trait). (iliaal)
2123

2224
- OpenSSL:
2325
. Fixed timeout for supplemental read at end of a blocking stream in SSL

ext/opcache/ZendAccelerator.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4368,12 +4368,14 @@ static void preload_fix_trait_op_array(zend_op_array *op_array)
43684368
uint32_t fn_flags = op_array->fn_flags;
43694369
zend_function *prototype = op_array->prototype;
43704370
HashTable *ht = op_array->static_variables;
4371+
const zend_property_info *prop_info = op_array->prop_info;
43714372
*op_array = *orig_op_array;
43724373
op_array->function_name = function_name;
43734374
op_array->scope = scope;
43744375
op_array->fn_flags = fn_flags;
43754376
op_array->prototype = prototype;
43764377
op_array->static_variables = ht;
4378+
op_array->prop_info = prop_info;
43774379
}
43784380

43794381
static void preload_fix_trait_methods(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)