New router and remove ids
Create two menu items:
Create 1 Category called Guides so the sub menu item of Blog has the same alias as the Category.
Create an article in the Guides category and view the blog View Menu Item. Click your new Article from this item and it will 404 error since it is trying to use the sub menu item in the URL.
Works withgout error
404 error
Labels |
Added:
?
|
Category | ⇒ | Router / SEF |
True, it’s not my doing. But it shouldn’t try to route through a menu item which is not capable of displaying the item. In this case a single article menu item.
On 26 Oct 2017, 14:52 +0100, Michael Babker notifications@github.com, wrote:
I'd almost call that expected behavior that it can't correctly route. In this scenario you are essentially creating two items with the same expected URI structure (/blog/guides).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
The bug is deeper than the routing, the routing just exposes it. You shouldn't be allowed to create content whose resolved URIs would be duplicated in general.
You can't expect the router to know what to do if it does the processing for a URI and it results in finding two configurations that could handle the route. It should raise an error (like it does now, intentional or not) because it could not resolve a unique content item.
Status | New | ⇒ | Discussion |
If you like ugly hack then you can use:
diff --git a/libraries/src/Component/Router/Rules/StandardRules.php b/libraries/src/Component/Router/Rules/StandardRules.php
index f8b2c2544e..37a14e47f2 100644
--- a/libraries/src/Component/Router/Rules/StandardRules.php
+++ b/libraries/src/Component/Router/Rules/StandardRules.php
@@ -79,6 +79,16 @@ class StandardRules implements RulesInterface
return;
}
+ if ($segments && !$views[$vars['view']]->children && !$views[$vars['view']]->nestable)
+ {
+ // Fall back to parent of active
+ array_unshift($segments, $active->alias);
+ $active = $this->router->menu->getItem($active->parent_id);
+ $vars['view'] = $active->query['view'];
+ $vars['id'] = $active->query['id'];
+ $this->router->menu->setActive($active->id);
+ }
+
// Copy the segments, so that we can iterate over all of them and at the same time modify the original segments
$tempSegments = $segments;
Thanks thomas, for me I can work around it. It’s not a big deal, but for sure integrators and end users they simply will not understand why it’s not working. And a negative hit for us again.
We need to prevent this from happening or advise on why it’s a 404? Personally I would expect the core to look for an alternative if it was a 404 for instance..
I would certainly like to see diagnostic information displayed if JDEBUG is on rather than a 404 or a "You are not authorised to view this resource."
Labels |
Added:
J3 Issue
|
Title |
|
Thank you for raising this issue.
Joomla 3 is now in security only mode with no further bug fixes or new features.
As this issue doesn't relate to Joomla 4 it will now been closed.
If we are mistaken and this does apply to Joomla 4 please open a new issue (and reference this one if you wish) with updated details for testing in Joomla 4.
cc @zero-24
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-08-23 13:47:50 |
Closed_By | ⇒ | zero-24 | |
Labels |
Added:
No Code Attached Yet
Removed: ? |
I'd almost call that expected behavior that it can't correctly route. In this scenario you are essentially creating two items with the same expected URI structure (
/blog/guides
).