Bug #97263
openfindPageCandidatesOfMountPoint breaks slugs if mount points to a folder and slugs start with the same string
0%
Description
Example Configuration:
1 Site 1: www.example.com
2 --- Folder: "Example" with Slug: "/example"
3 ------- Page: "Example 1" with Slug: "/example-1"
4 Site 2: subdomain.example.com
5 --- Cross site mount: "Example mount" with slug "/example-mount" mounting folder 2
When a menu of subpages is generated for 5 the resulting url of mounted page 3 will be:
https://subdomain.example.com/example-mount/-1 instead of https://subdomain.example.com/example-mount/example-1
Reason:
In method findPageCandidatesOfMountPoint of core/Classes/Routing/PageRouter.php the $commonSlugPrefixOfMountedPage will be removed from $slugOfSubpage even if the mounted page is a folder or spacer.
// Rewrite the slug of the subpage to match the PageRouter matching again
// This is done by first removing the "common" prefix possibly provided by the Mounted Page
// But more importantly adding the $slugOfMountPoint of the MountPoint Page
$slugOfSubpage = $pageCandidate['slug'];
if ($mountedPage['doktype'] === 1 && $commonSlugPrefixOfMountedPage && strpos($slugOfSubpage, $commonSlugPrefixOfMountedPage) === 0) {
$slugOfSubpage = substr($slugOfSubpage, strlen($commonSlugPrefixOfMountedPage));
}
Possible solution:
Check doktype of mounted page before removing $commonSlugPrefixOfMountedPage.
Updated by Dominik Steinborn over 2 years ago
Example Configuration:
1 Site 1: www.example.com
2 --- Folder: "Example" with Slug: "/example"
3 ------- Page: "Example 1" with Slug: "/example-1"
4 Site 2: subdomain.example.com
5 --- Cross site mount: "Example mount" with slug "/example-mount" mounting folder 2
When a menu of subpages is generated for 5 the resulting url of mounted page 3 will be:
https://subdomain.example.com/example-mount/-1 instead of https://subdomain.example.com/example-mount/example-1
Reason:
In method findPageCandidatesOfMountPoint of core/Classes/Routing/PageRouter.php the $commonSlugPrefixOfMountedPage will be removed from $slugOfSubpage even if the mounted page is a folder or spacer.
// Rewrite the slug of the subpage to match the PageRouter matching again
// This is done by first removing the "common" prefix possibly provided by the Mounted Page
// But more importantly adding the $slugOfMountPoint of the MountPoint Page
$slugOfSubpage = $pageCandidate['slug'];
if ($commonSlugPrefixOfMountedPage && strpos($slugOfSubpage, $commonSlugPrefixOfMountedPage) === 0) {
$slugOfSubpage = substr($slugOfSubpage, strlen($commonSlugPrefixOfMountedPage));
}
Possible solution:
Check doktype of mounted page before removing $commonSlugPrefixOfMountedPage.
Updated by Dominik Steinborn over 2 years ago
Dominik Steinborn wrote in #note-1:
Example Configuration:
1 Site 1: www.example.com
2 --- Folder: "Example" with Slug: "/example"
3 ------- Page: "Example 1" with Slug: "/example-1"4 Site 2: subdomain.example.com
5 --- Cross site mount: "Example mount" with slug "/example-mount" mounting folder 2When a menu of subpages is generated for 5 the resulting url of mounted page 3 will be:
https://subdomain.example.com/example-mount/-1 instead of https://subdomain.example.com/example-mount/example-1Reason:
In method findPageCandidatesOfMountPoint of core/Classes/Routing/PageRouter.php the $commonSlugPrefixOfMountedPage will be removed from $slugOfSubpage even if the mounted page is a folder or spacer.
[...]Possible solution:
Check doktype of mounted page before removing $commonSlugPrefixOfMountedPage.
This should be an edit of the issue text. The original issue text includes a modification I made in the code snippet which is not in the original code.
Updated by Oliver Hader about 2 years ago
- Sprint Focus set to On Location Sprint
Updated by Oliver Hader about 2 years ago
- Related to Bug #94963: PageRouter generates invalid URLs for access restricted mountpoints added