akeeba / sociallogin

Joomla!™ login and user account creation with Facebook, Google, GitHub etc social media accounts
29 stars 9 forks source link

Issue after Joomla! 5 upgrade #110

Closed mlacecilia closed 9 months ago

mlacecilia commented 9 months ago

Upgrading a working site from Joomla 4 to 5, a message is sent on login:

Joomla\CMS\Event\User\AbstractLoginEvent::onSetSubject(): Argument #1 ($value) must be of type array, null given, called in /membri/angrywordselite/libraries/src/Event/AbstractEvent.php on line 2250/membri/angrywordselite/libraries/src/Event/User/AbstractLoginEvent.php42Array

Isn't a blocking message because pressing browser back button or retrying the login the authentication succeed. Updating Joomla to 5.0.1 doesn't solve the issue.

image

nikosdion commented 9 months ago

Ah, the Joomla! maintainers managed to screw up the code I had contributed a couple of years ago to prevent exactly this kind of issue. Sigh…

The onUserAfterLogin event only takes one argument: options. With the code I had contributed, concrete events would take a single parameter: options.

They stupidly added a second parameter, subject, which is not used, for stupid reasons (to save about ten lines of code). However, if it's not provided as an empty array but as an implied NULL, as the core Joomla! code we have to use to allow the plugin to also run on Joomla! 4.3, Joomla! 5.0 throws a fatal error, therefore breaking backwards compatibility. 🤦🏽‍♂️

Maintaining a modicum of backwards compatibility isn't brain surgery. This whole issue could have been avoided in the first place by adding a simple method override for the subject setter in the concrete event class for onUserAfterLogin which accepts mixed and throws it away. Of course, they don't even let me file bug reports anymore, so this simple, easily correctable mistake will remain unfixed in Joomla! itself. Double sigh…

Anyway, I could work around it, the workaround is really simple, and it doesn't hurt Joomla! 4. So here you go.

Edit plugins/system/sociallogin/src/Library/Plugin/LoginTrait.php. Find

$this->runPlugins('onUserAfterLogin', [$options]);

and change it to

$this->runPlugins('onUserAfterLogin', [$options, []]);

This fix will make it into the next version – which I am not going to release until next week. Meanwhile, you can do the simple change above to get your site working again.

mlacecilia commented 9 months ago

Hi Nicholas. Thanks a lot! I understand what's the issue and I'll patch it ASAP. Thanks for your precious contributions to Joomla!. Best regards.

Maurizio

Il Sab 2 Dic 2023, 23:21 Nicholas K. Dionysopoulos @.***> ha scritto:

Ah, the Joomla! maintainers managed to screw up the code I had contributed a couple of years ago to prevent exactly this kind of issue. Sigh…

The onUserAfterLogin event only takes one argument: options. With the code I had contributed, concrete events would take a single parameter: options.

They stupidly added a second parameter, subject, which is not used, for stupid reasons (to save about ten lines of code). However, if it's not provided as an empty array but as an implied NULL, as the core Joomla! code we have to use to allow the plugin to also run on Joomla! 4.3, Joomla! 5.0 throws a fatal error, therefore breaking backwards compatibility. 🤦🏽‍♂️

Maintaining a modicum of backwards compatibility isn't brain surgery. This whole issue could have been avoided in the first place by adding a simple method override for the subject setter in the concrete event class for onUserAfterLogin which accepts mixed and throws it away. Of course, they don't even let me file bug reports anymore, so this simple, easily correctable mistake will remain unfixed in Joomla! itself. Double sigh…

Anyway, I could work around it, the workaround is really simple, and it doesn't hurt Joomla! 4. So here you go.

Edit plugins/system/sociallogin/src/Library/Plugin/LoginTrait.php. Find

$this->runPlugins('onUserAfterLogin', [$options]);

and change it to

$this->runPlugins('onUserAfterLogin', [$options, []]);

This fix will make it into the next version – which I am not going to release until next week. Meanwhile, you can do the simple change above to get your site working again.

— Reply to this email directly, view it on GitHub https://github.com/akeeba/sociallogin/issues/110#issuecomment-1837267932, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATLNKXXCXKKOE526T6DM5LYHOSW7AVCNFSM6AAAAABADLTJZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZXGI3DOOJTGI . You are receiving this because you authored the thread.Message ID: @.***>