[4.3] Routing: enforcing segment comparison for categories #39803
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
The content component routers have a situation where they behave unintentional. When a category has a subcategory and a content item (for example an article) with the same ID and the "remove IDs" option is disabled, the router will choose the subcategory over the content item, regardless of the alias. This is because the router compares the current segment it processes against the available childcategories and only if that fails, it switches over to checking against the articles.
Up till now, the check only compared the leading ID of the segment and not the complete segment with ID AND alias. This PR changes that and tightens the comparison. This would fix the above mentioned issue and prevent broken URLs from working. That last part however is also the biggest issue. If people actually rely on broken URLs (for example pasting them into a field which actually isn't long enough for the pasted content.) this would break those URLs.
Unfortunately an automatic fallback is not possible. If we have this new behavior and then fall back on the old behavior when no match was made, we would end up at exactly the same point we are now. I also would strongly vote against adding another option for this, because I don't think we can convoy the function of such an option to our users. It would lead to some cargo cult behavior, I fear.
Since this is a potential backwards compatibility issue, I'm asking for a vote from the production department on this PR.
Testing Instructions
Actual result BEFORE applying this Pull Request
The article with the same ID is displayed.
Expected result AFTER applying this Pull Request
The correct subcategory is displayed.
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