You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have some functional tests and need to disable a few subscribers that are not important for the test environment. The only way that I figured out was to manually remove them during the test setup.
I also have 2 subscribers, that subscribe to this event - NotificationSubscriber and AnotherSubscriber
I remove NotificationSubscriber from the manager as shown above, which means, that only AnotherSubscriber remains.
Problem is, when removing NotificationSubscriber, there's this code in Kdyby\Events\EventManager on line 222
foreach ((array) $unsubscribeas$eventName) {
foreach ($this->listeners[$eventName] as$priority => $listeners) {
if (($key = array_search($subscriber, $listeners, TRUE)) === FALSE) {
continue;
}
unset($this->listeners[$eventName][$priority][$key]);
if (empty($this->listeners[$eventName][$priority])) {
unset($this->listeners[$eventName][$priority]);
}
if (empty($this->listeners[$eventName])) {
unset($this->listeners[$eventName]);
}
// there are no listeners for this specific event, so no reason to call sort on next dispatch$this->sorted[$eventName] = array();
}
}
Particularly, the issue is with this line
// there are no listeners for this specific event, so no reason to call sort on next dispatch$this->sorted[$eventName] = array();
This effectively causes that $this->sorted['onSave'] is set to an empty array, even tough it should still contain AnotherSubscriber. Later, when the event is dispatched, the listeners are fetched from this array, which results in no subscribers being called, event tough AnotherSubscriber is still registered in Kdyby\Events\EventManager::listeners.
The text was updated successfully, but these errors were encountered:
I have some functional tests and need to disable a few subscribers that are not important for the test environment. The only way that I figured out was to manually remove them during the test setup.
It looks something like this
I found a bug tough.
onSave
NotificationSubscriber
andAnotherSubscriber
I remove
NotificationSubscriber
from the manager as shown above, which means, that onlyAnotherSubscriber
remains.Problem is, when removing
NotificationSubscriber
, there's this code inKdyby\Events\EventManager
on line 222Particularly, the issue is with this line
This effectively causes that
$this->sorted['onSave']
is set to an empty array, even tough it should still containAnotherSubscriber
. Later, when the event is dispatched, the listeners are fetched from this array, which results in no subscribers being called, event toughAnotherSubscriber
is still registered inKdyby\Events\EventManager::listeners
.The text was updated successfully, but these errors were encountered: