diff --git a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php index 911b6ac115499734534aff867d60bdc162969996..15adce19d2de290414a9c2b47d0d18561d8a8128 100644 --- a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php +++ b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php @@ -815,7 +815,9 @@ class EditDocumentController { // add/override parameters by configuration if (isset($previewConfiguration['additionalGetParameters.'])) { - $linkParameters = array_replace($linkParameters, $previewConfiguration['additionalGetParameters.']); + $additionalGetParameters = []; + $this->parseAdditionalGetParameters($additionalGetParameters, $previewConfiguration['additionalGetParameters.']); + $linkParameters = array_replace($linkParameters, $additionalGetParameters); } $this->popViewId = $previewPageId; @@ -834,6 +836,27 @@ class EditDocumentController { }'; } + /** + * Migrates a set of (possibly nested) GET parameters in TypoScript syntax to a plain array + * + * This basically removes the trailing dots of sub-array keys in TypoScript. + * The result can be used to create a query string with GeneralUtility::implodeArrayForUrl(). + * + * @param array $parameters Should be an empty array by default + * @param array $typoScript The TypoScript configuration + */ + protected function parseAdditionalGetParameters(array &$parameters, array $typoScript) { + foreach ($typoScript as $key => $value) { + if (is_array($value)) { + $key = rtrim($key, '.'); + $parameters[$key] = []; + $this->parseAdditionalGetParameters($parameters[$key], $value); + } else { + $parameters[$key] = $value; + } + } + } + /** * Main module operation * diff --git a/typo3/sysext/backend/Tests/Unit/Controller/EditDocumentControllerTest.php b/typo3/sysext/backend/Tests/Unit/Controller/EditDocumentControllerTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1db0bca93d8bcfd877af4c225a0b6fe192f03b10 --- /dev/null +++ b/typo3/sysext/backend/Tests/Unit/Controller/EditDocumentControllerTest.php @@ -0,0 +1,49 @@ +<?php +namespace TYPO3\CMS\Backend\Tests\Unit\Controller; + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +use TYPO3\CMS\Backend\Controller\EditDocumentController; +use TYPO3\CMS\Core\Tests\UnitTestCase; + +/** + * Tests for EditDocumentController + */ +class EditDocumentControllerTest extends UnitTestCase { + + /** + * @test + */ + public function parseAdditionalGetParametersCreatesCorrectParameterArray() { + $typoScript = [ + 'tx_myext.' => [ + 'controller' => 'test', + 'action' => 'run' + ], + 'magic' => 'yes' + ]; + $expectedParameters = [ + 'tx_myext' => [ + 'controller' => 'test', + 'action' => 'run' + ], + 'magic' => 'yes' + ]; + $result = []; + $mock = $this->getAccessibleMock(EditDocumentController::class, ['dummy'], [], '', FALSE); + $mock->_callRef('parseAdditionalGetParameters', $result, $typoScript); + $this->assertSame($expectedParameters, $result); + } + +} diff --git a/typo3/sysext/core/Documentation/Changelog/7.2/Feature-66370-AddFlexiblePreviewUrlConfiguration.rst b/typo3/sysext/core/Documentation/Changelog/7.2/Feature-66370-AddFlexiblePreviewUrlConfiguration.rst index b224c3a97ff02664c994b3b3cb66ab056157dbe6..2e3d672fb64063e58caa96a4658a9c474159fc11 100644 --- a/typo3/sysext/core/Documentation/Changelog/7.2/Feature-66370-AddFlexiblePreviewUrlConfiguration.rst +++ b/typo3/sysext/core/Documentation/Changelog/7.2/Feature-66370-AddFlexiblePreviewUrlConfiguration.rst @@ -29,7 +29,7 @@ New page TSconfig is introduced. The options are: uid = tx_myext_pi1[showUid] } additionalGetParameters { - tx_myext_pi1[special] = HELLO + tx_myext_pi1.special = HELLO # results in tx_myext_pi1[special] } } }