Commit eda84c1a authored by Benni Mack's avatar Benni Mack
Browse files

[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's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent f9753264
......@@ -147,7 +147,7 @@ class PageTypeDecorator extends AbstractEnhancer implements DecoratingEnhancerIn
// If the type is > 0 but the value could not be resolved,
// the type is appended as GET argument, which can be resolved already anyway.
// This happens when the PageTypeDecorator is used, but hasn't been configured for all available types.
if ($value === '' && !empty($type)) {
if (!empty($type) && ($value === '' || $value === $this->default)) {
return;
}
......
......@@ -15,7 +15,10 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling;
* 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 @@ class EnhancerLinkGeneratorTest extends AbstractTestCase
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);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment