?
avatar MacTrophy
MacTrophy
8 Mar 2019

Steps to reproduce the issue

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.

Expected result

Shouldn't raise an error!

IMO the JEvent should handle this and properly setup the $args array to avoid this situation

Actual result

Too few arguments to function PlgAuthenticationCookie::onUserAfterLogout(), 0 passed in libraries/joomla/event/event.php on line 70 and exactly 1 expected

System information (as much as possible)

Joomla 3.9.3
PHP 7.2 (AFAIK was not problematic under 5.6)
Debian 9 fully updated

Additional comments

avatar MacTrophy MacTrophy - open - 8 Mar 2019
avatar joomla-cms-bot joomla-cms-bot - labeled - 8 Mar 2019
avatar mbabker
mbabker - comment - 8 Mar 2019

PlgAuthenticationCookie::onUserAfterLogout() requires at least one parameter, so JEventDispatcher::getInstance()->trigger('onUserAfterLogout') or JEventDispatcher::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.

avatar joomla-cms-bot joomla-cms-bot - change - 8 Mar 2019
Status Expected Behaviour Closed
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 8 Mar 2019
avatar franz-wohlkoenig franz-wohlkoenig - change - 8 Mar 2019
Status New Expected Behaviour
Closed_Date 0000-00-00 00:00:00 2019-03-08 19:39:46
Closed_By franz-wohlkoenig
avatar joomla-cms-bot
joomla-cms-bot - comment - 8 Mar 2019
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 8 Mar 2019

closed as expected Behaviour.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/24130.

Add a Comment

Login with GitHub to post a comment