Skip to content

[4.3] Fixing Itemid lookup in tags router in multilang#40474

Merged
obuisard merged 16 commits intojoomla:4.3-devfrom
Hackwar:4.3-tag-router
May 13, 2023
Merged

[4.3] Fixing Itemid lookup in tags router in multilang#40474
obuisard merged 16 commits intojoomla:4.3-devfrom
Hackwar:4.3-tag-router

Conversation

@Hackwar
Copy link
Copy Markdown
Member

@Hackwar Hackwar commented Apr 24, 2023

Pull Request for Issue #40454.

Summary of Changes

When running in multilanguage mode, the router falsely only checked for the current language or the default language, not for all (*) language when looking up the right Itemid. This executes the logic twice, once for the current language, once for the * language. It exits for the first matched menu item.

Testing Instructions

  1. Install Joomla
  2. Install at least one additional language
  3. Install multilanguage sample data
  4. Install testing sample data
  5. Go to for example the popular tags module. You can find it in the "Popular tags" menu item.
  6. Check the URLs

Actual result BEFORE applying this Pull Request

URLs start with /component/tags/...

Expected result AFTER applying this Pull Request

URLs have different menu items. None start with /component/tags

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

@richard67
Copy link
Copy Markdown
Member

Does this PR conflict somehow with PR #40455 ? Or would they work together?

@Hackwar
Copy link
Copy Markdown
Member Author

Hackwar commented Apr 24, 2023

This PR does not conflict with #40455

@sdwjoomla
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 73cc2ca

Test site with 3 languages installed (sample data) and pagination for one of the tags

With published menu item /component/ not present
Without published menu item /component/ not present

in either case no itemid


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

@sdwjoomla
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 18d024d


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

@MacJoom
Copy link
Copy Markdown
Contributor

MacJoom commented Apr 25, 2023

I have tested this item 🔴 unsuccessfully on 18d024d

The links on the Homepage below in Popular Tags (after index.php)
Joomla 4.2.9 before Tagged-content Menu Language en-GB
/en/component/tags/tag/millions-en-gb /en/component/tags/tag/worldwide-en-gb /en/component/tags/tag/love-en-gb /en/component/tags/tag/joomla-4-en-gb

with Tagged content Language Menu en-GB with Tags 'Millions' 'Love', tagged-content within 'Millions' and 'Love' (tagged in Menu)
/en/tagged-content/millions-en-gb /en/component/tags/tag/worldwide-en-gb /en/tagged-content/love-en-gb /en/component/tags/tag/joomla-4-en-gb

after Joomla 4.3.0 - component and itemid
/en/component/tags/tag/millions-en-gb?Itemid=104 /en/component/tags/tag/worldwide-en-gb?Itemid=104 /en/component/tags/tag/love-en-gb?Itemid=104 /en/component/tags/tag/joomla-4-en-gb?Itemid=104

after applying Patch 40474 - itemid gone but still with component
/en/component/tags/tag/millions-en-gb /en/component/tags/tag/worldwide-en-gb /en/component/tags/tag/love-en-gb /en/component/tags/tag/joomla-4-en-gb


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

@richard67
Copy link
Copy Markdown
Member

richard67 commented Apr 25, 2023

@Hackwar Shouldn't the $language be changed to $lang in lines 131 and 138 as those come below the for loop?

&& ($language === '*' || \in_array($active->language, ['*', $language]) || !Multilanguage::isEnabled()))
) {
$query['Itemid'] = $active->id;
}
// If not found, return language specific home link
if (!isset($query['Itemid'])) {
$default = $this->menu->getDefault($language);

@Hackwar
Copy link
Copy Markdown
Member Author

Hackwar commented Apr 25, 2023

Indeed, that needs to be changed.

@Hackwar
Copy link
Copy Markdown
Member Author

Hackwar commented Apr 25, 2023

done

@obuisard
Copy link
Copy Markdown
Contributor

Martin @MacJoom can you double-check if that fixes it?

@obuisard
Copy link
Copy Markdown
Contributor

Will this PR render #40460 obsolete?

@richard67
Copy link
Copy Markdown
Member

Will this PR render #40460 obsolete?

@obuisard Yes, this here is a replacement for that one. But I think this here is maybe not ready yet. It still not worked for me, but I am not sure if all was right with my test. The other one did not fully work either.

@Fedik
Copy link
Copy Markdown
Member

Fedik commented Apr 25, 2023

Will this PR render #40460 obsolete?

They both produce identical result, however I think Hannes know Joomla Routing better than me, so I have closed mine.

@obuisard
Copy link
Copy Markdown
Contributor

Will this PR render #40460 obsolete?

They both produce identical result, however I think Hannes know Joomla Routing better than me, so I have closed mine.

Fedir @Fedik, thank you so much for looking into it and providing a solution, this is really appreciated.

@MacJoom
Copy link
Copy Markdown
Contributor

MacJoom commented Apr 25, 2023

There is unfortunatly exactly the same result as before - being on f2240e5 - i can switch to the 4.2.9 branch with the same db and i have the original result.

@MacJoom
Copy link
Copy Markdown
Contributor

MacJoom commented Apr 25, 2023

Btw. The testing instructions above are missing the step to setup a menu item with the tagged items in en-gb between steps 5 and 6 (on my test site the menu item has the alias 'tagged-content' as the links for 4.2.9 show) and if this menu item is set to language 'all' the links will stay on 'component' - this may be a clue.

@joomdonation
Copy link
Copy Markdown
Contributor

To be more clear, the issue here is that if you create a menu item to link to Tagged Items menu item type and select two tags A and B :

  • In Joomla 4.2 and earlier, link to tag A and tag B will use the above menu item as active menu item
  • In Joomla 4.3, link to tag A and tag B does not use the above menu item as active menu item although the menu item contains these two tags.

There was changed to the logic of code to find active menu item for a tag for some reasons. Unless the tagged items menu item type only select a single tag, it won't be used for link to a tag like before.

@obuisard
Copy link
Copy Markdown
Contributor

Doing testing and getting same results as Martin @MacJoom.

@Hackwar
Copy link
Copy Markdown
Member Author

Hackwar commented Apr 25, 2023

Indeed, the lookup was changed, since the old code was unable to find menu items with more than one tag assigned to them. So if you created a URL with 2 tags, it couldn't find a menu item at all. Fixing that now results in menu items with multiple tags not matching to URLs with a single tag. I personally think that tags are a filter on the content and those filters compound, so a URL with two tags should only display the content which has both tags assigned to it, but apparently I'm wrong there, since the tagging code doesn't behave that way later on in the model.

I will change the code to match it again.

@Hackwar
Copy link
Copy Markdown
Member Author

Hackwar commented Apr 25, 2023

Done.

@obuisard
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 6e3e4c3

The last change seems to do it for me:

Tags that are associated to menu items are properly opening in that menu item (use of the alias of the menu item),
Tags that are not associated to menu items open in the home page (/component/tags/tag in the path).

Behavior is consistent to 4.2, no longer dimmed as b/c as far as I can tell.


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

@Hackwar
Copy link
Copy Markdown
Member Author

Hackwar commented May 8, 2023

@joeforjoomla Can you please answer @richard67 and me? This is a rather important issue and we are all waiting for you to either substantiate your claim or to merge this PR to be ready in time for 4.3.2. If you don't respond in 3 days, I will suggest to ignore your report.

@obuisard obuisard added this to the Joomla! 4.3.2 milestone May 8, 2023
@joeforjoomla
Copy link
Copy Markdown
Contributor

joeforjoomla commented May 8, 2023

@Hackwar @richard67 i would expect to have tag links as before:

http://joomla4/en/menualias/tag/tag1.html
http://joomla4/en/menualias/tag/tag2.html

and not for all tags:

http://joomla4/en/menualias.html

Why this? How to have a tag link then? What is the sense of this router?

@Hackwar
Copy link
Copy Markdown
Member Author

Hackwar commented May 9, 2023

I reviewed the whole code of tags again and you are right @joeforjoomla. I'm going to see what I can do here.

@Hackwar Hackwar removed the RTC This Pull Request is Ready To Commit label May 9, 2023
@joomla-cms-bot joomla-cms-bot removed this from the Joomla! 4.3.2 milestone May 9, 2023
@richard67
Copy link
Copy Markdown
Member

Back to pending in the issue tracker.


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

@richard67 richard67 added this to the Joomla! 4.3.2 milestone May 9, 2023
@Fedik Fedik mentioned this pull request May 10, 2023
4 tasks
@obuisard obuisard added the Updates Requested Indicates that this pull request needs an update from the author and should not be tested. label May 11, 2023
@Hackwar
Copy link
Copy Markdown
Member Author

Hackwar commented May 11, 2023

@joeforjoomla Please check if this change fixes your issues.

@richard67 richard67 removed the Updates Requested Indicates that this pull request needs an update from the author and should not be tested. label May 11, 2023
@joeforjoomla
Copy link
Copy Markdown
Contributor

joeforjoomla commented May 11, 2023

@joeforjoomla Please check if this change fixes your issues.

@Hackwar Just perfect! :)

@joeforjoomla
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on d5a6863


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

@richard67
Copy link
Copy Markdown
Member

I have tested this item ✅ successfully on d5a6863

URLs now after the last change are like they were in 4.2.9, i.e. everything as expected now.


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

@richard67 richard67 added the Updates Requested Indicates that this pull request needs an update from the author and should not be tested. label May 13, 2023
@joomla-cms-bot joomla-cms-bot removed this from the Joomla! 4.3.2 milestone May 13, 2023
@richard67
Copy link
Copy Markdown
Member

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label May 13, 2023
@richard67 richard67 removed the Updates Requested Indicates that this pull request needs an update from the author and should not be tested. label May 13, 2023
@richard67 richard67 added this to the Joomla! 4.3.2 milestone May 13, 2023
@obuisard obuisard merged commit 09a03cf into joomla:4.3-dev May 13, 2023
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label May 13, 2023
@obuisard
Copy link
Copy Markdown
Contributor

Thank you Hannes @Hackwar and all testers, your help is greatly appreciated. Great team work.

@Hackwar Hackwar deleted the 4.3-tag-router branch March 22, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants