I think calling anything with the JEventDispatcher->trigger
with an event name and no args OR an empty args array will result in a error.
In my plugin I am calling
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onUserAfterLogout'); // trigger('onUserAfterLogout', array()); is also problematic
to get the PlgAuthenticationCookie
to do it's job. If the 2nd parameter to trigger is not specified or I pass array()
, I will get
Too few arguments to function PlgAuthenticationCookie::onUserAfterLogout(), 0 passed in libraries/joomla/event/event.php on line 70 and exactly 1 expected
if I call $dispatcher->trigger('onUserAfterLogout', array('whatever' => 'whatever'));
it will work!
The problem seems to come from the call in JEvent->update(&$args)
where the method call_user_func_array
is called, PHP seems to NOT assign anything to the arguments of the triggered method if the array is empty.
Shouldn't raise an error!
IMO the JEvent should handle this and properly setup the $args array to avoid this situation
Too few arguments to function PlgAuthenticationCookie::onUserAfterLogout(), 0 passed in libraries/joomla/event/event.php on line 70 and exactly 1 expected
Joomla 3.9.3
PHP 7.2 (AFAIK was not problematic under 5.6)
Debian 9 fully updated
Status | Expected Behaviour | ⇒ | Closed |
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
Status | New | ⇒ | Expected Behaviour |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-03-08 19:39:46 |
Closed_By | ⇒ | franz-wohlkoenig |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/24130
closed as expected Behaviour.
PlgAuthenticationCookie::onUserAfterLogout()
requires at least one parameter, soJEventDispatcher::getInstance()->trigger('onUserAfterLogout')
orJEventDispatcher::getInstance()->trigger('onUserAfterLogout', [])
won't work. You must provide at least one value in the arguments array. So, this would be an expected behavior, not because of an issue in the event dispatcher but rather the listeners for an event.