Skip to content

[EventDispatcher] fix empty prio #35260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

hjanuschka
Copy link
Contributor

Q A
Branch? master
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #35259
License MIT

returns 0 instead of null as it is typ hinted on other places anyway, and leads to exceptions sometimes.

@ro0NL
Copy link
Contributor

ro0NL commented Jan 8, 2020

* @return int|null The event listener priority
*/
public function getListenerPriority(string $eventName, $listener);

should we update the contract then? Or just the wrongful calling sides?

@hjanuschka
Copy link
Contributor Author

@ro0NL thx, good point, pushed changes

@nicolas-grekas
Copy link
Member

This looks suspicious to me. It looks like a BC break.

@nicolas-grekas nicolas-grekas added this to the next milestone Jan 8, 2020
@@ -94,7 +94,7 @@ public function getListeners(string $eventName = null)
public function getListenerPriority(string $eventName, $listener)
{
if (empty($this->listeners[$eventName])) {
return null;
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong to me. The interface states this:

Returns null if the event or the listener does not exist.

Making this change here violates the contract defined by the interface.

@@ -114,7 +114,7 @@ public function getListenerPriority(string $eventName, $listener)
}
}

return null;
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same above

@@ -62,7 +62,7 @@ public function getListeners(string $eventName = null);
*
* @param callable $listener The listener
*
* @return int|null The event listener priority
* @return int The event listener priority, defaults to 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing this is a BC break

@lyrixx lyrixx changed the title fix empty prio [EventDispatcher] fix empty prio Jan 9, 2020
@hjanuschka hjanuschka closed this Jan 9, 2020
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.1 May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EventListener Broken with 5.0.x
5 participants