From db9b98d54efef4cbfb41ee295738ee93cf0fbb27 Mon Sep 17 00:00:00 2001 From: Benni Mack Date: Mon, 3 May 2021 21:20:46 +0200 Subject: [PATCH] [BUGFIX] Keep unmapped ?type parameter when using PageTypeDecorator This change keeps the type parameter (e.g. ?type=13) even if PageTypeDecorator is used when building URLs but "13" is not part of the map in the site configuration. A test is added in order to make sure this functionality will not break (again), see https://review.typo3.org/c/Packages/TYPO3.CMS/+/62383 for the original fix without tests. Resolves: #87104 Related: #87817 Related: #88836 Releases: master, 10.4, 9.5 Change-Id: Ic7f82bfa9f28f971162e1af1b557188f61446462 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69116 Tested-by: core-ci Tested-by: Benni Mack Reviewed-by: Benni Mack --- .../EnhancerLinkGeneratorTest.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Tests/Functional/SiteHandling/EnhancerLinkGeneratorTest.php b/Tests/Functional/SiteHandling/EnhancerLinkGeneratorTest.php index 85b93ba2d..1dd4f8735 100644 --- a/Tests/Functional/SiteHandling/EnhancerLinkGeneratorTest.php +++ b/Tests/Functional/SiteHandling/EnhancerLinkGeneratorTest.php @@ -15,7 +15,10 @@ * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Configuration\SiteConfiguration; use TYPO3\CMS\Core\Core\Bootstrap; +use TYPO3\CMS\Core\Site\SiteFinder; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\ApplicableConjunction; use TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\AspectDeclaration; use TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Builder; @@ -1177,4 +1180,33 @@ public function defaultExtbaseControllerActionNamesAreAppliedWithAdditionalNonMa self::assertSame($expectation, (string)$response->getBody()); } + + /** + * @test + */ + public function unmappedPageTypeDecoratorIsAddedAsRegularQueryParam(): void + { + $this->mergeSiteConfiguration('archive-acme-com', [ + 'routeEnhancers' => [ + 'PageType' => [ + 'type' => 'PageType', + 'default' => '/', + 'index' => '', + 'map' => [ + '/' => 0, + 'sitemap.xml' => '1533906435' + ] + ] + ] + ]); + + GeneralUtility::makeInstance(SiteConfiguration::class, $this->instancePath . '/typo3conf/sites/')->getAllExistingSites(false); + $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByIdentifier('archive-acme-com'); + $uri = $site->getRouter()->generateUri(3000); + self::assertEquals('https://archive.acme.com/', (string)$uri); + $uri = $site->getRouter()->generateUri(3000, ['type' => '1533906435']); + self::assertEquals('https://archive.acme.com/sitemap.xml', (string)$uri); + $uri = $site->getRouter()->generateUri(3000, ['type' => '13']); + self::assertEquals('https://archive.acme.com/?type=13', (string)$uri); + } }