[BUGFIX] Fetching configuration-comments should require no comma 65/50265/5
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 18 Oct 2016 13:55:07 +0000 (15:55 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 24 Oct 2016 13:22:08 +0000 (15:22 +0200)
So far a comma was required before the comment. But CGL says that
the last element in an array should have no trailing comma.

Change-Id: Ia8149624e1b5bb1d4a685b70f3c197344733e22f
Resolves: #78333
Releases: master, 7.6
Reviewed-on: https://review.typo3.org/50265
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/install/Classes/Controller/Action/Tool/AllConfiguration.php

index 998690f..43d75a3 100644 (file)
@@ -211,27 +211,24 @@ class AllConfiguration extends Action\AbstractAction
 
         $commentArray = [];
         $lines = explode(LF, $string);
-        $in = 0;
+        $inConfiguration = false;
         $mainKey = '';
         foreach ($lines as $lc) {
             $lc = trim($lc);
-            if ($in) {
+            if ($inConfiguration) {
                 if ($lc === '];') {
-                    $in = 0;
-                } else {
-                    if (preg_match('/["\']([[:alnum:]_-]*)["\'][[:space:]]*=>(.*)/i', $lc, $reg)) {
-                        preg_match('/,[\\t\\s]*\\/\\/(.*)/i', $reg[2], $creg);
-                        $theComment = trim($creg[1]);
-                        if (substr(trim($reg[2]), 0, 1) === '[' && $reg[1] === strtoupper($reg[1])) {
-                            $mainKey = trim($reg[1]);
-                        } elseif ($mainKey) {
-                            $commentArray[$mainKey][$reg[1]] = $theComment;
-                        }
+                    break;
+                }
+                if (preg_match('#["\']([\\w_-]*)["\']\\s*=>\\s*(?:(\\[).*|(?!//).*//\\s*(.*))#i', $lc, $reg)) {
+                    if ($reg[2] === '[' && $reg[1] === strtoupper($reg[1])) {
+                        $mainKey = $reg[1];
+                    } elseif ($mainKey) {
+                        $commentArray[$mainKey][$reg[1]] = $reg[3];
                     }
                 }
             }
             if ($lc === 'return [') {
-                $in = 1;
+                $inConfiguration = true;
             }
         }
         return $commentArray;