[BUGFIX] Do not sort tree nodes after each append 29/52729/2
authorChrister Vindberg <cvi@systime.dk>
Thu, 27 Apr 2017 09:30:21 +0000 (11:30 +0200)
committerJan Helke <typo3@helke.de>
Fri, 5 May 2017 17:13:31 +0000 (19:13 +0200)
Nodes should not be sorted after each element append but only once at
the end.

This will reduce the execution time of
DatabaseTreeDataProvider::buildRepresentationForNode() a lot e.g. when
a category menu tree is generated.

Resolves: #81039
Releases: master, 8.7
Change-Id: I9cb57630f0179a0b2b3c921ca1eb97e7455ce962
Reviewed-on: https://review.typo3.org/52729
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Tested-by: TYPO3com <no-reply@typo3.com>
typo3/sysext/core/Classes/Tree/TableConfiguration/DatabaseTreeDataProvider.php

index b561522..27974de 100644 (file)
@@ -269,9 +269,12 @@ class DatabaseTreeDataProvider extends AbstractTableConfigurationTreeDataProvide
             $node->setHasChildren(true);
             /** @var $childNodes \TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection */
             $childNodes = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\SortedTreeNodeCollection::class);
+            $tempNodes = [];
             foreach ($basicNode->getChildNodes() as $child) {
-                $childNodes->append($this->buildRepresentationForNode($child, $node, $level + 1));
+                $tempNodes[] = $this->buildRepresentationForNode($child, $node, $level + 1);
             }
+            $childNodes->exchangeArray($tempNodes);
+            $childNodes->asort();
             $node->setChildNodes($childNodes);
         }
         return $node;