File tree 3 files changed +17
-4
lines changed
3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ Yii Framework 2 Change Log
7
7
- Bug #16509 : Fixed console command help text wordwrap for multi-byte strings (alexkart)
8
8
- Bug #17299 : Fixed adding of input error class in ` \yii\widgets\ActiveField::widget ` (alexkart)
9
9
- Bug #17328 : Added mime aliases for BMP and SVG files (cmoeke)
10
+ - Bug #17336 : Fixed wildcard matching in Event::hasHandlers() (samdark)
10
11
11
12
12
13
2.0.19 May 21, 2019
Original file line number Diff line number Diff line change @@ -225,8 +225,8 @@ class_implements($class, true)
225
225
);
226
226
227
227
// regular events
228
- foreach ($ classes as $ class ) {
229
- if (!empty (self ::$ _events [$ name ][$ class ])) {
228
+ foreach ($ classes as $ className ) {
229
+ if (!empty (self ::$ _events [$ name ][$ className ])) {
230
230
return true ;
231
231
}
232
232
}
@@ -240,8 +240,8 @@ class_implements($class, true)
240
240
if (empty ($ handlers )) {
241
241
continue ;
242
242
}
243
- foreach ($ classes as $ class ) {
244
- if (! StringHelper::matchWildcard ($ classWildcard , $ class )) {
243
+ foreach ($ classes as $ className ) {
244
+ if (StringHelper::matchWildcard ($ classWildcard , $ className , [ ' escape ' => false ] )) {
245
245
return true ;
246
246
}
247
247
}
Original file line number Diff line number Diff line change @@ -91,6 +91,18 @@ public function testHasHandlers()
91
91
$ this ->assertTrue (Event::hasHandlers ('yiiunit\framework\base\SomeInterface ' , SomeInterface::EVENT_SUPER_EVENT ));
92
92
}
93
93
94
+ /**
95
+ * @see https://github.com/yiisoft/yii2/issues/17336
96
+ */
97
+ public function testHasHandlersWithWildcard ()
98
+ {
99
+ Event::on ('\yiiunit\framework\base\* ' , 'save.* ' , function ($ event ) {
100
+ // do nothing
101
+ });
102
+
103
+ $ this ->assertTrue (Event::hasHandlers ('yiiunit\framework\base\SomeInterface ' , 'save.it ' ), 'save.it ' );
104
+ }
105
+
94
106
public function testOffUnmatchedHandler ()
95
107
{
96
108
$ this ->assertFalse (Event::hasHandlers (Post::className (), 'afterSave ' ));
You can’t perform that action at this time.
0 commit comments