[BUGFIX] Better positionName extraction in executePositionedStringInsertion 32/47832/4
authorChristian Weiske <weiske@mogic.com>
Thu, 21 Apr 2016 07:09:57 +0000 (09:09 +0200)
committerFrans Saris <franssaris@gmail.com>
Thu, 21 Apr 2016 10:48:22 +0000 (12:48 +0200)
Limit string explosion so that "LLL:EXT:" notation in $position
does not get broken up.

Resolves: #75830
Releases: master, 7.6
Change-Id: I13cc15562bd790040c3e45c9eb27ff029311c78f
Reviewed-on: https://review.typo3.org/47832
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/core/Classes/Utility/ExtensionManagementUtility.php
typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php

index 10d538d..47977da 100644 (file)
@@ -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);
index dc5f207..6d2a380 100644 (file)
@@ -338,6 +338,22 @@ class ExtensionManagementUtilityTest extends UnitTestCase
     }
 
     /**
+     * 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
      *
      * @test