Fix tagged items URLs for items with the same view #43379
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of Changes
"Tags > List of tagged items" view uses
Joomla\Component\Tags\Site\Helper\RouteHelper::getItemRoute()
to get a URL of individual item.It uses
Joomla\CMS\Helper\RouteHelper::getRoute()
, if noJPATH_BASE . '/components/' . $explodedAlias[0] . '/helpers/route.php'
is found.Assuming that we have modern components with Router service, the tagged item URL is generated via
Joomla\CMS\Helper\RouteHelper::getRoute()
.This method adds the Itemid via this code:
The problem is that the new routers are using the NoMenuRule and can auto-find the correct Itemid themselves.
Hence, there is no need to auto-find the Itemid here.
Another problem is that
Joomla\CMS\Helper\RouteHelper::findItem()
uses internal static cache of needles per view name.Hence, if we have multiple components with the same view name, the second component will receive invalid Itemid because its URL generation will use the needles cache of the first component with the same view name.
Testing Instructions
Create multiple tagged items from different component but with the same view name.
Actual result BEFORE applying this Pull Request
See broken URLs if you browser the list of tagged items where we have the items from different components but the same view.
Expected result AFTER applying this Pull Request
Correct URLs respecting the components' specific Itemids.
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