#97468RouteEnhancer ignores db tables when slug option "unique" is used
Description
Hey,
it seems that there is a problem with the “unique” slug option and RouteEnhancers when different db tables use the same string in the slugs.
I used the “unique” option for slug fields for a webpage with multiple site configurations to be able to display projects and news on both sites.
In my case there is a project and a news with the same name, e.g. slug => “test”.
If several projects have “test” then a “-1” is added, so no problem at this point.
However, when a news and a reference have the same name, the RouteEnhancer seems to ignore in which table the slug is unique.
In the view of the listAction I display all news.
But when I click the showAction link, the action parameter for the domain model is always “null”.
But only as long as the RouteEnhancer is not commented out in the yaml file.
This problem only occurred when I used “unique”.
I had no errors with “uniqueInSite” or “uniqueInPid”.
If I remove the RouteEnhancer again, it works again.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 3
-
Bastian Bringenberg commented and changed project id category TYPO3 Version 11 <span data-processor="relativetime" data-value="2022-04-25T12:38:50+00:00" > 04/25/22, 12:38 </span>
-
Christian Dorka commented <span data-processor="relativetime" data-value="2022-04-25T12:46:41+00:00" > 04/25/22, 12:46 </span>
Bastian Bringenberg wrote in #note-1:
> Moved Project.
> Guessed TYPO3 Version.Yes the TYPO3 version in use is 11.5.9
-
Georg Ringer commented and changed status
NewClosed <span data-processor="relativetime" data-value="2026-10-03T05:04:35+00:00" > 10/03/26, 05:04 </span>Thanks for the report. This is not a bug in the routing but caused by overlapping routes of two route enhancers.
Why this happens
When a URL is resolved, all routes of the page are checked one after another. The first route whose path pattern matches and whose aspects can be resolved wins. Only if an aspect cannot be resolved, the next route is tried.
A route enhancer without
limitToPagesis applied to all pages. If the news and the project enhancer use the same path pattern, e.g./{news-title}and/{project-title}, both routes match the URL/test:- If the first route has a fallback value (e.g. by using the aspect
NewsTitleof EXT:news or a configuredfallbackValue), it always resolves, falling back tonullif no record is found. The other route is never tried, and the action receivesnull– which is exactly what you see. - Without a fallback value, a slug that exists in both tables resolves with the record of the wrong table, and the argument ends up in the wrong plugin.
The slug option
uniqueonly guarantees uniqueness within one table, so the same slug in two tables is expected. The aspects do not take the slug options into account when matching a URL, so the behaviour withuniqueInSiteoruniqueInPidis most likely only different because the slugs did not overlap there.How to solve it
Make sure the routes do not overlap, by using either a static prefix per enhancer:
routeEnhancers: News: type: Extbase extension: News plugin: Pi1 routes: - routePath: '/news/{news-title}' _controller: 'News::detail' _arguments: news-title: news Project: type: Extbase # ... routes: - routePath: '/project/{project-title}' # ...or by restricting each enhancer to its detail page(s):
routeEnhancers: News: type: Extbase limitToPages: - 123This is also explained in the EXT:news documentation, see Fallbacks & Pitfalls.
I am closing this issue. If the problem persists with a prefix or
limitToPages, please add your site configuration and the issue can be reopened. - If the first route has a fallback value (e.g. by using the aspect
Moved Project.
Guessed TYPO3 Version.