Skip to content

Commit 873bb13

Browse files
committed
Fix zend_function.prop_info pointer for trait hooks
Fixes GH-15240
1 parent 49d0d7b commit 873bb13

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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)