Skip to content
Snippets Groups Projects
Commit 2625d6b4 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/+/68978


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarHenrik Elsner <helsner@dfau.de>
Tested-by: default avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarHenrik Elsner <helsner@dfau.de>
Reviewed-by: default avatarRémy DANIEL <dogawaf@no-log.org>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
parent 6c99d1ad
No related branches found
No related tags found
No related merge requests found
......@@ -148,7 +148,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;
}
......
......@@ -17,6 +17,9 @@ declare(strict_types=1);
namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\EnhancerSiteRequest;
use TYPO3\CMS\Core\Configuration\SiteConfiguration;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\Builder;
use TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\LanguageContext;
use TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Framework\Builder\TestSet;
......@@ -138,4 +141,33 @@ class PageTypeDecoratorTest extends AbstractEnhancerSiteRequestTest
$pageArguments = json_decode((string)$response->getBody(), true);
self::assertEquals($expectation, $pageArguments);
}
/**
* @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)->resolveAllExistingSites(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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment