Skip to content

Commit 43f688e

Browse files
authored
Fix zend_function.prop_info pointer for trait hooks (#15245)
Fixes GH-15240
1 parent 50217b3 commit 43f688e

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ PHP NEWS
55
- Core:
66
. Updated build system scripts config.guess to 2024-07-27 and config.sub to
77
2024-05-27. (Peter Kokot)
8+
. Fixed bug GH-15240 (Infinite recursion in trait hook). (ilutov)
89

910
- Date:
1011
. Constants SUNFUNCS_RET_TIMESTAMP, SUNFUNCS_RET_STRING, and SUNFUNCS_RET_DOUBLE

Zend/tests/gh15240.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-15240: Trait hook leads to infinite recursion
3+
--FILE--
4+
<?php
5+
6+
trait T {
7+
public $prop {
8+
set => $value;
9+
}
10+
}
11+
12+
class C {
13+
use T;
14+
}
15+
16+
$c = new C;
17+
$c->prop = 42;
18+
var_dump($c->prop);
19+
20+
?>
21+
--EXPECT--
22+
int(42)

Zend/zend_inheritance.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,6 +2833,7 @@ static void zend_do_traits_property_binding(zend_class_entry *ce, zend_class_ent
28332833
memcpy(new_fn, old_fn, sizeof(zend_op_array));
28342834
new_fn->op_array.fn_flags &= ~ZEND_ACC_IMMUTABLE;
28352835
new_fn->common.fn_flags |= ZEND_ACC_TRAIT_CLONE;
2836+
new_fn->common.prop_info = new_prop;
28362837
function_add_ref(new_fn);
28372838

28382839
zend_fixup_trait_method(new_fn, ce);

0 commit comments

Comments
 (0)