File tree Expand file tree Collapse file tree 2 files changed +58
-1
lines changed Expand file tree Collapse file tree 2 files changed +58
-1
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #80929: Method name corruption related to zend_closure_call_magic
3
+ --FILE--
4
+ <?php
5
+ class DefaultListener
6
+ {
7
+ public function handleDefaultEvent ($ event ) { }
8
+ }
9
+
10
+ class SubscriberProxy
11
+ {
12
+ private array $ subscribedEvents ;
13
+ private object $ subscriber ;
14
+ private Closure $ listener ;
15
+
16
+ public function __construct (array $ subscribedEvents , object $ subscriber )
17
+ {
18
+ $ this ->subscribedEvents = $ subscribedEvents ;
19
+ $ this ->subscriber = $ subscriber ;
20
+ foreach ($ this ->subscribedEvents as $ eventName => $ params ) {
21
+ $ this ->listener = Closure::fromCallable ([$ this , $ params ]);
22
+ }
23
+ }
24
+
25
+ public function __call (string $ name , array $ arguments )
26
+ {
27
+ return $ this ->subscriber ->$ name (...$ arguments );
28
+ }
29
+
30
+ public function dispatch ($ event , string $ eventName )
31
+ {
32
+ ($ this ->listener )($ event , $ eventName , null );
33
+ }
34
+ }
35
+
36
+ $ proxy = new SubscriberProxy (
37
+ ['defaultEvent ' => 'handleDefaultEvent ' ],
38
+ new DefaultListener ()
39
+ );
40
+
41
+ for ($ i = 0 ; $ i < 10 ; $ i ++) {
42
+ echo $ i . PHP_EOL ;
43
+ $ proxy ->dispatch (null , 'defaultEvent ' );
44
+ }
45
+ ?>
46
+ --EXPECT--
47
+ 0
48
+ 1
49
+ 2
50
+ 3
51
+ 4
52
+ 5
53
+ 6
54
+ 7
55
+ 8
56
+ 9
Original file line number Diff line number Diff line change @@ -290,7 +290,6 @@ static ZEND_NAMED_FUNCTION(zend_closure_call_magic) /* {{{ */ {
290
290
291
291
zend_call_function (& fci , & fcc );
292
292
293
- zval_ptr_dtor (& fci .params [0 ]);
294
293
zval_ptr_dtor (& fci .params [1 ]);
295
294
}
296
295
/* }}} */
@@ -491,6 +490,8 @@ static void zend_closure_free_storage(zend_object *object) /* {{{ */
491
490
zend_destroy_static_vars (& closure -> func .op_array );
492
491
}
493
492
destroy_op_array (& closure -> func .op_array );
493
+ } else if (closure -> orig_internal_handler == zend_closure_call_magic ) {
494
+ zend_string_release (closure -> func .common .function_name );
494
495
}
495
496
496
497
if (Z_TYPE (closure -> this_ptr ) != IS_UNDEF ) {
You can’t perform that action at this time.
0 commit comments