No Code Attached Yet
avatar PhilETaylor
PhilETaylor
27 Dec 2021

Ok @wilsonge you up for this challenge?

when a user is not logged in

Factory::getApplication()->getIdentity() = null

whereas

Factory::getUser() = an empty Joomla\CMS\User\User object

!!!

The back end is fine - its only the frontend having issues, PluginHelper and SiteApplication seem to be the two files that need touching but I cannot seem to find the "right way" to do this.

It seems that Joomla is highly dependant on getUser returning a empty User class when not logged in... so that ->getAuthorisedLevels() and other methods can be run on a guest user.

The deprecation message therefore is wrong as the two methods are not the same. getUser loads from self::getApplication()->getSession()->get('user') and getIdentify just loads from the class property - and is null if the user is logged out.

Or is the correct "fix" to refactor most of the frontend, and all the 3PD extensions so that they check getIdentity and see if its null or not before using it? ... but then you could have ACL on your logged out users - but as your logged out user is NULL and not a blank user object that levels can be checked on... you are screwed... haha.

Until this is resolved, the use of Factory::getApplication()->getIdentity() on the frontend, where users could be logged out, should be minimised...

Installation is also broken (unit tests show that)

Originally posted by @PhilETaylor in #36447 (comment)

avatar PhilETaylor PhilETaylor - open - 27 Dec 2021
avatar joomla-cms-bot joomla-cms-bot - change - 27 Dec 2021
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Dec 2021
avatar PhilETaylor PhilETaylor - change - 27 Dec 2021
The description was changed
avatar PhilETaylor PhilETaylor - edited - 27 Dec 2021
avatar PhilETaylor PhilETaylor - change - 27 Dec 2021
Title
[5] `Factory::getUser` is not the same as `Factory::getApplication()->getIdentity()`
[5] `Factory::getUser()` is not the same as `Factory::getApplication()->getIdentity()`
avatar PhilETaylor PhilETaylor - edited - 27 Dec 2021
avatar PhilETaylor PhilETaylor - change - 27 Dec 2021
Title
[5] `Factory::getUser()` is not the same as `Factory::getApplication()->getIdentity()`
[5] Deprecated `Factory::getUser()` is not the same as `Factory::getApplication()->getIdentity()`
avatar PhilETaylor PhilETaylor - edited - 27 Dec 2021
avatar PhilETaylor PhilETaylor - change - 1 Jan 2022
The description was changed
avatar PhilETaylor PhilETaylor - edited - 1 Jan 2022
avatar PhilETaylor PhilETaylor - change - 7 Mar 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-03-07 18:40:19
Closed_By PhilETaylor
avatar PhilETaylor PhilETaylor - close - 7 Mar 2022
avatar codeling
codeling - comment - 30 Nov 2023

This is still the case in the released 5.0.0 I presume? Then I guess this should be prominently mentioned in https://manual.joomla.org/migrations/44-50/ ...?

Add a Comment

Login with GitHub to post a comment