diff --git a/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php b/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php index 10d538d9864830859106c4c4a5ba14eb60dd0149..47977da6a068a164dfe0ed87f4edacc8160a0934 100644 --- a/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php +++ b/typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php @@ -647,7 +647,7 @@ class ExtensionManagementUtility { $list = $newList = trim($list, ", \t\n\r\0\x0B"); - list($location, $positionName) = GeneralUtility::trimExplode(':', $insertionPosition); + list($location, $positionName) = GeneralUtility::trimExplode(':', $insertionPosition, false, 2); if ($location !== 'replace') { $insertionList = self::removeDuplicatesForInsertion($insertionList, $list); @@ -670,7 +670,7 @@ class ExtensionManagementUtility $positionName = str_replace(';;', ';[^;]*;', $positionName); } - $pattern = ('/(^|,\\s*)(' . $positionName . ')(;[^,$]+)?(,|$)/'); + $pattern = ('/(^|,\\s*)(' . preg_quote($positionName, '/') . ')(;[^,$]+)?(,|$)/'); switch ($location) { case 'after': $newList = preg_replace($pattern, '$1$2$3, ' . $insertionList . '$4', $list); diff --git a/typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php index dc5f2074263af9e12cad6149fa955b604166bb79..6d2a38048e37c2fd7c9348d0527f15370376b7cd 100644 --- a/typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php +++ b/typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php @@ -337,6 +337,22 @@ class ExtensionManagementUtilityTest extends UnitTestCase $this->assertEquals('fieldA, fieldB, fieldC;labelC, newA, newB, --palette--;;paletteC, fieldC1, fieldD, fieldD1', $GLOBALS['TCA'][$table]['types']['typeB']['showitem']); } + /** + * Tests whether fields can be add to all TCA types and duplicate fields are considered. + * + * @test + * @see ExtensionManagementUtility::addToAllTCAtypes() + */ + public function canAddFieldsToAllTCATypesRespectsPalettes() + { + $table = $this->getUniqueId('tx_coretest_table'); + $GLOBALS['TCA'] = $this->generateTCAForTable($table); + $GLOBALS['TCA'][$table]['types']['typeD'] = ['showitem' => 'fieldY, --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.standard;standard, fieldZ']; + ExtensionManagementUtility::addToAllTCAtypes($table, 'newA, newA, newB, fieldA', '', 'after:--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.standard;standard'); + // Checking typeD: + $this->assertEquals('fieldY, --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.palettes.standard;standard, newA, newB, fieldA, fieldZ', $GLOBALS['TCA'][$table]['types']['typeD']['showitem']); + } + /** * Tests whether fields can be add to a TCA type before existing ones *