Revert "[TASK] Avoid slow array functions in loops"
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / ContentObject / ContentObjectRenderer.php
index a8b1007..c7a4b10 100644 (file)
@@ -5884,7 +5884,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
         $allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol,t3ver_state' . $addSelectFields;
         $depth = (int)$depth;
         $begin = (int)$begin;
-        $theList = [[]];
+        $theList = [];
         $addId = 0;
         $requestHash = '';
 
@@ -6033,7 +6033,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
                     // Add ID to list:
                     if ($begin <= 0) {
                         if ($dontCheckEnableFields || $tsfe->checkEnableFields($row)) {
-                            $theList[] = [$next_id];
+                            $theList[] = $next_id;
                         }
                     }
                     // Next level:
@@ -6044,27 +6044,28 @@ class ContentObjectRenderer implements LoggerAwareInterface
                         }
                         // Call recursively, if the id is not in prevID_array:
                         if (!in_array($next_id, $prevId_array)) {
-                            $theList[] = GeneralUtility::intExplode(
-                                ',',
-                                $this->getTreeList(
-                                    $next_id,
-                                    $depth - 1,
-                                    $begin - 1,
-                                    $dontCheckEnableFields,
-                                    $addSelectFields,
-                                    $moreWhereClauses,
-                                    $prevId_array,
-                                    $recursionLevel + 1
+                            $theList = array_merge(
+                                GeneralUtility::intExplode(
+                                    ',',
+                                    $this->getTreeList(
+                                        $next_id,
+                                        $depth - 1,
+                                        $begin - 1,
+                                        $dontCheckEnableFields,
+                                        $addSelectFields,
+                                        $moreWhereClauses,
+                                        $prevId_array,
+                                        $recursionLevel + 1
+                                    ),
+                                    true
                                 ),
-                                true
+                                $theList
                             );
                         }
                     }
                 }
             }
         }
-        $theList = array_merge(...$theList);
-
         // If first run, check if the ID should be returned:
         if (!$recursionLevel) {
             if ($addId) {
@@ -6274,13 +6275,16 @@ class ContentObjectRenderer implements LoggerAwareInterface
                         $storagePid = -$storagePid;
                     }
                 });
-                $expandedPidList = [[]];
+                $expandedPidList = [];
                 foreach ($pidList as $value) {
                     // Implementation of getTreeList allows to pass the id negative to include
                     // it into the result otherwise only childpages are returned
-                    $expandedPidList[] = GeneralUtility::intExplode(',', $this->getTreeList($value, $conf['recursive']));
+                    $expandedPidList = array_merge(
+                        GeneralUtility::intExplode(',', $this->getTreeList($value, $conf['recursive'])),
+                        $expandedPidList
+                    );
                 }
-                $conf['pidInList'] = implode(',', array_merge(...$expandedPidList));
+                $conf['pidInList'] = implode(',', $expandedPidList);
             }
         }
         if ((string)$conf['pidInList'] === '') {