#91342No PID is checked in FE when TCA slug field has uniqueInPid in eval
Description
I really like eval options uniqueInSite and uniqueInPid in the slug field. But I don’t understand how the uniqueInPid option is resolved in the frontend.
In my project I have similar structure to this:
- Folder A
- Folder B
- Detail page A … (Record storage in the Plugin tab is set to “Folder A”)
- Detail page B … (Record storage in the Plugin tab is set to “Folder B”)
Suppose we have our own object type (eg. Project) and different types of projects stored in different folders. 1st type is stored in “Folder A” and displayed on “Detail page A”, 2nd type use “Folder B” and “Detail page B”. When I save two different projects with the same name in different folders, the same slug will be generated for them (eg. big-project), which is fine due to the uniqueInPid option.
Now, in the frontend I get two different URLs:
- /detail-page-a/big-project … (should display project from “Folder A”)
- /detail-page-b/big-project … (should display project from “Folder B”)
But in both cases the first “big-project” from table is displayed, the record storage (field [pages]) is ignored. The TYPO3\CMS\Core\Routing\Aspect\PersistedAliasMapper use language and frontend (deleted, hidden etc.) restrictions but there is no check for PID.
Is this a misconfiguration or a bug?
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 4
-
Jiří Štefl changed subject
No PID is checked when TCA slug field has uniqueInPid in evalNo PID is checked in FE when TCA slug field has uniqueInPid in eval <span data-processor="relativetime" data-value="2020-05-07T19:34:04+00:00" > 05/07/20, 19:34 </span> -
Rémy DANIEL commented <span data-processor="relativetime" data-value="2023-03-30T08:37:09+00:00" > 03/30/23, 08:37 </span>
It is more that the uniqueInPid is suitable if the slug contains also the rootline, which it is not the case for records other than pages.
When PersistedAliasMapper decode an url segment (slug) to a record uid, he has actually no way to restrict the db query in a particular pid (where this pid should be encoded in the url ?)
IMHO, the only solution is to always add the uid of the record to the generatorOptions/fields: uniqueInPid is then obviously useless.
'config' => [ 'type' => 'slug', 'generatorOptions' => [ 'fields' => ['uid','title'], 'fieldSeparator' => '/', 'replacements' => [ '/' => '', ], ], 'fallbackCharacter' => '-', ], -
Benni Mack commented and changed status
NewClosed <span data-processor="relativetime" data-value="2026-10-23T08:54:24+00:00" > 10/23/26, 08:54 </span>Thanks for the report, and sorry it took so long to get an answer.
This is a limitation of how slugs are resolved, not a bug. uniqueInPid only controls uniqueness when a record is saved: two records in different folders may get the same slug. When a URL like /detail-page-a/big-project is resolved, PersistedAliasMapper only gets the slug. Routing runs before any plugin, so the mapper doesn’t know about the plugin’s record storage (pages) setting, and the URL contains nothing else it could filter by. It can narrow the lookup to the current site (with uniqueInSite), but not to a folder, so it takes the first matching record.
If records must resolve from a slug alone, make the slug unique where it’s resolved:
- use uniqueInSite (or unique) instead of uniqueInPid for the slug field, or
- if the same title has to appear in several folders, put something that tells the records apart into the slug, e.g. the uid (as Rémy suggested: ‘generatorOptions’ => [‘fields’ => [‘uid’, ‘title’], …]).I’m closing this as “works as designed”. If you’d like the mapper to be limited to certain folders (e.g. a storagePids option on the route aspect), please open a feature request.
Same problem here. In the frontend the first record found is checked no matter which pid is assigned. How to fix it?