? ? Success

User tests: Successful: Unsuccessful:

avatar weeblr
weeblr
8 Oct 2020

Pull Request for Issue #11541 .

Summary of Changes

AbstracMenu and SiteMenu classes use a memoized copy of the current user. Under some circumstances, this causes incorrect menu items to be displayed when user is logged in through the Remember-me feature (registered-access level items not shown) as the user has not yet been updated to logged-in state.

Circumstances are that Application::getMenu() is called from a plugin early on, typically from a system plugin constructor or onAfterInitialise.

getMenu() may not be called directly but for instance calling Application::getRouter() to add parse or build rules triggers the problem because the router itself grabs the menu in its contructor.

The language filter plugin does that, any SEF extension will also attach routing rules as well as many other extensions.

For 3rd party extensions, the problem will appear less frequently because it is also a requirement that the plugin in question is located before the RememberMe plugin, which is not common but will happen when user re-order plugins or when extensions want to the be the 1st plugin in the list for instance.

Comments

  1. The problem affects Joomla 3 and Joomla 4 the same. Testing instructions are the same. I think however the issue should be solved differently in J3 and J4. This PR is for Joomla 3 and fixes the problem simply, in the most B/C manner.

  2. With Joomla 4, the same code can be used and will also solve the problem. But I think a more robust approach should be used. It would make sense the Remember me plugin is located first in the list of system plugins. It would even make more sense that logging-in through the remember me feature is embedded in the CMS app and not in a plugin. Such logging-in should happen exactly as early as if the user was logged-in through the session or else there's a risk of similar side-effects happening in other areas, where some parts of the code see the user as a guest while later on it's seen as logged-in.

  3. This issue was identified in 2016 (#11541)and a fix proposed at the time but unfortunately never merged. This PR uses a slightly different method which only touches the Menu class, not the remember me plugin. I believe it's better to do it that way, especially for Joomla 3, so that no changes are needed in 3rd-party extensions providing features similar to Remember-me, or otherwise.

Testing Instructions

From a stock Joomla 3 install:

  1. Disable Caching in Global configuration
  2. Create a menu item GUEST with access level "guest"
  3. Create a menu item REGISTERED with access level "registered"
  4. Enable the Language Filter system plugin
  5. Log out of admin
  6. On front end, GUEST menu item should be displayed
  7. Log in to the front end **make sure to tick the Remember me check box"
  8. The REGISTERED menu item is shown, GUEST menu item is hidden
  9. Close your browser:
    • the entire browser, not just the current tab
    • browser must NOT be set to "reload all tabs opened when it was closed".
  10. Navigate to your test site URL again by pasting it in the address bar

Step 9 & 10 can be replaced by deleting some cookies, faster to test but requires knowledge of browser dev tools. See end of this description.

Actual result BEFORE applying this Pull Request

The GUEST menu item is displayed despite the user being logged in and the login module showing the user as Logged in. The REGISTERED menu item is not displayed.

Expected result AFTER applying this Pull Request

The REGISTERED menu item is displayed and the GUEST one is not shown.

Note on testing:

Rather than closing browser at each attempt, you can simulate the same behavior with the development tools:

  1. Open the dev tools at Application->Cookies
  2. After logging-in with Remember me checked - step 8, you'll see (at least) 3 cookies:
  • joomla_remember_me_xxxx
  • joomla_user_state_xxx
  • session cookie that looks like "433f42e5e0d104622fd1b9c1c38b3945"

To simulate closing the browser, you can delete the joomla_user_state cookie and the session cookie. After that, just reload the page to reproduce step 10.

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar weeblr weeblr - open - 8 Oct 2020
avatar weeblr weeblr - change - 8 Oct 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 8 Oct 2020
Category Libraries
avatar AndySDH AndySDH - test_item - 8 Oct 2020 - Tested successfully
avatar AndySDH
AndySDH - comment - 8 Oct 2020

I have tested this item successfully on 9ea1a38


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

avatar weeblr weeblr - change - 8 Oct 2020
Labels Added: ?
avatar HLeithner
HLeithner - comment - 8 Oct 2020

We have a b/c problem on this PR, if we remove $this->user and someone extends this class he/she expects that $this->user is populated with the current user...

avatar weeblr
weeblr - comment - 8 Oct 2020

@HLeithner I know. I tried to minimize B/C breaks while still fixing the problem. As this issue appears on pretty much any multilingual site that has non-public content, I think it's pretty important to fix.

How about I use a magic getter function instead of a getUser() method?

avatar weeblr
weeblr - comment - 8 Oct 2020

@HLeithner Redone it with a magic getter. Also removed getUser() but left setUser(). Not sure that's needed anymore actually.

avatar gostn gostn - test_item - 26 Oct 2020 - Tested successfully
avatar SharkyKZ
SharkyKZ - comment - 26 Oct 2020

My 2c this is the wrong approach. I think Remember Me plugin is in the wrong. It should perform a redirect after login. This would solve potential issues anywhere else where user instance could be cached.

avatar ashvini77 ashvini77 - test_item - 7 Nov 2020 - Tested unsuccessfully
avatar ashvini77
ashvini77 - comment - 7 Nov 2020

I have tested this item ? unsuccessfully on 4ee37e2

500 error displayed on the frontend.


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

avatar snehaM26 snehaM26 - test_item - 7 Nov 2020 - Tested unsuccessfully
avatar snehaM26
snehaM26 - comment - 7 Nov 2020

I have tested this item ? unsuccessfully on 4ee37e2

I test this item. It gives an error when clicked on the menu at the frontend with Guest ACL after Patch is applied.


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

avatar infograf768
infograf768 - comment - 7 Nov 2020

Folks, this is for staging, NOT 4.0.

avatar gostn gostn - test_item - 10 Nov 2020 - Not tested
avatar weeblr
weeblr - comment - 10 Nov 2020

Hi @ashvini77 @snehaM26

Can you redo your test against the Joomla 3 staging branch?

Thank you

avatar weeblr
weeblr - comment - 1 Feb 2021

Hi

We do have more feedback about this problem from the field!

@ashvini77 @snehaM26 can you redo your testing (against Joomla 3, not Joomla 4)?

Best regards

avatar AndySDH AndySDH - test_item - 25 Feb 2021 - Tested successfully
avatar AndySDH
AndySDH - comment - 25 Feb 2021

I have tested this item successfully on 849849c

Tested the latest version successfully.

It fixes the issue as described.

Thanks @weeblr!


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

avatar web54
web54 - comment - 26 Feb 2021

succesfull tested on a new multilingal hosted site

avatar weeblr
weeblr - comment - 26 Feb 2021

@HLeithner @infograf768 can this be merged now? (I know the second Human tester did not use Patch Tester)

avatar HLeithner
HLeithner - comment - 26 Feb 2021

sorry to late for 3.9.25

Anyway the redirect mentioned by sharky would solve the problem too right?

avatar weeblr
weeblr - comment - 26 Feb 2021

Hi

If the issue is created by the Remember me plugin, yes.

This fixes the problem for the menu system, meaning it'd be fixed regardless of the source.

avatar weeblr
weeblr - comment - 28 Feb 2021

Hi

I can see my last message is ambiguous so for clarity: the proposed redirect in Remember plugin does not fix the problem.

It only fixes it if the user object change is caused by the Remember me plugin. If the change is caused by another extension (typically extensions dealing with access such as subscription extension for instance), then the issue is still present.

avatar web54
web54 - comment - 5 Mar 2021

tested with success with patch tester :

Commit SHA appliqué : 849849c

I do not know nom how to indicate it passed the test succesfully

documentation https://docs.joomla.org/Testing_Joomla!_patches/fr tells about a test this button, but I do not see how to use it

helpers like me who just use windows and not comand lines are lost when they want help devs to debug

avatar richard67
richard67 - comment - 5 Mar 2021

@web54 You go to the PR in the issue tracker here https://issues.joomla.org/tracker/joomla-cms/30991 , then use the blue "Test this" button at the top left corner, then select the appropriate test result and then submit.

avatar web54 web54 - test_item - 5 Mar 2021 - Tested successfully
avatar web54
web54 - comment - 5 Mar 2021

I have tested this item successfully on 849849c

tested in local with ampps


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

avatar richard67 richard67 - change - 5 Mar 2021
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 5 Mar 2021

RTC


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

avatar rdeutz rdeutz - close - 15 Mar 2021
avatar rdeutz rdeutz - merge - 15 Mar 2021
avatar rdeutz rdeutz - change - 15 Mar 2021
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-03-15 10:10:06
Closed_By rdeutz
Labels Added: ?
avatar SharkyKZ
SharkyKZ - comment - 15 Mar 2021

Do maintainers not review the code anymore or what?

avatar rdeutz
rdeutz - comment - 15 Mar 2021

Do maintainers not review the code anymore or what?

Sure we do, what you are refering to?

Add a Comment

Login with GitHub to post a comment