Issue Bug New Orphaned

#97263findPageCandidatesOfMountPoint breaks slugs if mount points to a folder and slugs start with the same string

Dominik Steinborn 03/31/22, 08:53 updated 08/02/23, 13:05

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.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Fix this issue

Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch

Commit message
[BUGFIX] findPageCandidatesOfMountPoint breaks slugs if mount points to a folder and slugs start with the same string Resolves: #97263 Releases: main