Feature RTC PR-5.2-dev Pending

User tests: Successful: Unsuccessful:

avatar Hackwar
Hackwar
26 Mar 2024

This fixes issues #43154, #35463 and #39149

Summary of Changes

The router right now merges the query elements of the current menu item into the query it parsed so far. If no menu item was found, it merges in the values of the default menu item. This is quite a problem when the default menu item contains query elements which are not overwritten by the URL itself. One example would be our own schedule runner plugin with a default menu item linking to an article. This PR only merges in the menu items query when the menu item and the parsed option are identical. Most likely this doesn't solve the issue entirely, since you could have a component which still could fail in this constellation, but at least it wouldn't fail anymore for all the components out there which currently have the query from an article default menu item merged into their request.

Testing Instructions

  1. Switch the default menu item to a single article view and select a random article.
  2. Edit plugins/system/schedulerunner/src/Extension/ScheduleRunner.php and add var_dump($id);die; to line 206
  3. Go to System -> Scheduled Tasks -> Options -> WebCron and enable Web Cron.
  4. Save the options and later copy the link from that same place to run the webcron via ajax call.
  5. Open the link in a new tab.

Actual result BEFORE applying this Pull Request

The var_dump() returns a non-zero ID, even though there is no ID in the URL.

Expected result AFTER applying this Pull Request

The var_dump() correctly only returns a 0.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar Hackwar Hackwar - open - 26 Mar 2024
avatar Hackwar Hackwar - change - 26 Mar 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Mar 2024
Category Libraries
avatar alikon
alikon - comment - 27 Mar 2024

should'nt this be backported to 4.4 ? as per #43154

avatar uGE70 uGE70 - test_item - 27 Mar 2024 - Tested successfully
avatar uGE70
uGE70 - comment - 27 Mar 2024

I have tested this item ✅ successfully on 773a13f

Thanks a lot for your patch. I've tested it and the task id is returning zero now.


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

avatar Hackwar
Hackwar - comment - 27 Mar 2024

should'nt this be backported to 4.4 ? as per #43154

I'm unsure how this should be handled and asked the cms maintainer group about this. waiting for their feedback.

avatar Hackwar Hackwar - change - 27 Mar 2024
Labels Added: PR-5.2-dev
avatar Hackwar Hackwar - change - 30 Mar 2024
The description was changed
avatar Hackwar Hackwar - edited - 30 Mar 2024
avatar SniperSister SniperSister - test_item - 7 Apr 2024 - Tested successfully
avatar SniperSister
SniperSister - comment - 7 Apr 2024

I have tested this item ✅ successfully on 8accc62


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

avatar Quy Quy - alter_testresult - 8 Apr 2024 - uGE70: Tested successfully
avatar Quy Quy - change - 8 Apr 2024
Status Pending Ready to Commit
avatar Quy
Quy - comment - 8 Apr 2024

RTC


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

avatar Quy Quy - change - 8 Apr 2024
Labels Added: RTC
avatar Hackwar Hackwar - change - 9 Apr 2024
Title
[5.2] Router: Only merge default menu item when same component
[5.2] SEF/Router: Only merge default menu item when same component
avatar Hackwar Hackwar - edited - 9 Apr 2024
avatar Hackwar Hackwar - change - 29 Apr 2024
Labels Added: Feature
avatar joomla-cms-bot joomla-cms-bot - change - 3 May 2024
Category Libraries Libraries JavaScript Unit Tests
avatar Hackwar Hackwar - change - 6 May 2024
Labels Added: Unit/System Tests
avatar brianteeman
brianteeman - comment - 6 May 2024

Surely having to change an existing test that passes without this PR in order for it to pass with this PR is a red flag that something is wrong with this PR

avatar robbiejackson
robbiejackson - comment - 19 Jul 2024

Good to get this bug fixed! It shouldn't merge in the parameters of the home menuitem.

However, the code is now not setting the active menuitem. This is a problem as extension developers do use this.

In Joomla 3.x the active menuitem wasn't set in the case of the home menuitem being used as default.

Then in Joomla 4 it changed to being set.

So in my opinion we shouldn't be now changing it back to the case where it's not set.

If the balance of opinion is that it shouldn't be set then this side-effect needs to be clearly highlighted in the documentation of the pull request.

See https://docs.joomla.org/Menu_and_Menuitems_API_Guide#Active_Menu_Item and
https://manual.joomla.org/docs/general-concepts/menus-menuitems#active-menu-item

avatar joomla-cms-bot joomla-cms-bot - change - 19 Jul 2024
Category Libraries JavaScript Unit Tests Libraries
avatar Hackwar
Hackwar - comment - 19 Jul 2024

Thank you @robbiejackson. Your comment made me check this again and do a debugging session of several hours and after several checks I indeed agree that we should still set the active menu item. I changed the code accordingly. Good catch. Our code actually states that getActive() might return null when no menu item is set, but who reads docblocks? ;-)

avatar Hackwar
Hackwar - comment - 19 Jul 2024

@uGE70, @SniperSister, @robbiejackson could you test this again so that we hopefully can merge this into 5.2? Thank you!

avatar brianteeman
brianteeman - comment - 19 Jul 2024

Surely having to change an existing test that passes without this PR in order for it to pass with this PR is a red flag that something is wrong with this PR

image

whoever could have predicted that you dont edit a test to fix a problem

avatar uGE70 uGE70 - test_item - 19 Jul 2024 - Tested successfully
avatar uGE70
uGE70 - comment - 19 Jul 2024

I have tested this item ✅ successfully on 359bbde


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

avatar robbiejackson robbiejackson - test_item - 19 Jul 2024 - Tested successfully
avatar robbiejackson
robbiejackson - comment - 19 Jul 2024

I have tested this item ✅ successfully on 359bbde

Thanks for changing to keep the active menuitem :-)

I'll update the joomla manual documentation to confirm that the menuitem is now always set.


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

avatar Hackwar
Hackwar - comment - 19 Jul 2024

@robbiejackson this is actually something which I would keep vague for now. The getActive() method states that it can also return null and I'm currently still considering it to be more correct to not set the menu item in this case. However that would be a b/c break and thus has to wait until at least 6.0.

avatar Hackwar
Hackwar - comment - 19 Jul 2024

Thanks for the tests!

avatar Quy Quy - change - 19 Jul 2024
Labels Removed: Unit/System Tests
avatar zero-24 zero-24 - test_item - 21 Jul 2024 - Tested successfully
avatar zero-24
zero-24 - comment - 21 Jul 2024

I have tested this item ✅ successfully on bfa035f


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

avatar SniperSister SniperSister - test_item - 21 Jul 2024 - Tested successfully
avatar SniperSister
SniperSister - comment - 21 Jul 2024

I have tested this item ✅ successfully on bfa035f


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

avatar rdeutz rdeutz - close - 24 Jul 2024
avatar rdeutz rdeutz - merge - 24 Jul 2024
avatar rdeutz rdeutz - change - 24 Jul 2024
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2024-07-24 16:15:08
Closed_By rdeutz

Add a Comment

Login with GitHub to post a comment