diff --git a/typo3/sysext/core/Classes/Routing/PageSlugCandidateProvider.php b/typo3/sysext/core/Classes/Routing/PageSlugCandidateProvider.php index dd81d11b06caac4e73b876bf2d7b11c0137fda77..219e00fb5c74495eaf20ff957698f177fb7fe33f 100644 --- a/typo3/sysext/core/Classes/Routing/PageSlugCandidateProvider.php +++ b/typo3/sysext/core/Classes/Routing/PageSlugCandidateProvider.php @@ -247,18 +247,26 @@ class PageSlugCandidateProvider try { $isOnSameSite = $siteFinder->getSiteByPageId($pageIdInDefaultLanguage)->getRootPageId() === $this->site->getRootPageId(); - if ($isOnSameSite) { - $pages[] = $row; - $excludeUids[] = (int)$row['uid']; - } elseif ($mountedPage && $row['mount_pid_ol']) { + // If the page is a mountpoint which should be overlaid with the contents of the mounted page, + // it must never be accessible directly, but only in the mountpoint context. Therefore we change + // the current ID and slug. + if ($mountedPage && PageRepository::DOKTYPE_MOUNTPOINT === (int)$row['doktype'] && $row['mount_pid_ol']) { // If the mounted page was already added from above, this should not be added again (to include // the mount point parameter). if (in_array((int)$mountedPage['uid'], $excludeUids, true)) { continue; } - $mountedPage['MPvar'] = $mountPageInformation['MPvar']; - $pages[] = $mountedPage; - $excludeUids[] = (int)$mountedPage['uid']; + $pageToAdd = $mountedPage; + // Make sure target page "/about-us" is replaced by "/global-site/about-us" so router works + $pageToAdd['MPvar'] = $mountPageInformation['MPvar']; + $pageToAdd['slug'] = $row['slug']; + $pages[] = $pageToAdd; + $excludeUids[] = (int)$pageToAdd['uid']; + $excludeUids[] = $pageIdInDefaultLanguage; + } + if ($isOnSameSite && !in_array($pageIdInDefaultLanguage, $excludeUids, true)) { + $pages[] = $row; + $excludeUids[] = $pageIdInDefaultLanguage; } } catch (SiteNotFoundException $e) { // Page is not in a site, so it's not considered diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/MountPointTest.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/MountPointTest.php index 9894a4f529803107e41dec89997cda1636b77ac3..15a8e8dc392c56948b3ae1ed87b0eb3e5840bf3a 100644 --- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/MountPointTest.php +++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/MountPointTest.php @@ -492,43 +492,20 @@ class MountPointTest extends AbstractTestCase self::assertSame($expectedMountPointParameter, $responseData['dynamicArguments']['MP'] ?? null); } - /** - * @test - * @group not-postgres - * Does not work on postres currenly due to setUpFrontendRootPage which does not work with the database snapshotting - */ - public function accessingAMountPointDirectlyThatShouldNotBeAvailableTriggersARedirect() - { - $uri = 'https://acme.ca/all-news/canada'; - $targetUrl = 'https://acme.ca/all-news/canada/all-news/canada/'; - $this->setUpFrontendRootPage( - 2000, - [ - 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkRequest.typoscript', - ], - [ - 'title' => 'ACME Root', - 'sitetitle' => $this->siteTitle, - ] - ); - $response = $this->executeFrontendRequest( - (new InternalRequest($uri)), - $this->internalRequestContext - ); - self::assertSame(307, $response->getStatusCode()); - self::assertSame($targetUrl, $response->getHeaderLine('Location')); - } - /** * @return array */ public function mountPointPagesShowContentAsConfiguredDataProvider() { return [ - 'Show content of MountPoint page' => [ + 'Show content of MountPoint Page' => [ 'https://acme.ca/all-news/archive', 'Content of MountPoint Page' ], + 'Show content of Mounted Page' => [ + 'https://acme.ca/all-news/canada', + 'See a list of all games distributed in canada' + ], ]; }