[BUGFIX] getTreeList must return comma-separated list 39/56139/12
authorGuido Schmechel <littlegee@web.de>
Tue, 13 Mar 2018 20:22:03 +0000 (21:22 +0100)
committerFrans Saris <franssaris@gmail.com>
Wed, 16 May 2018 18:50:23 +0000 (20:50 +0200)
While retrieving the list with begin as argument for a
recursive call, getTreeList builds the comma-separated list
correctly.

Resolves: #83328
Releases: master, 8.7, 7.6
Change-Id: I643477dd5c0cbfb67532dd96eb0b479e0cb532b8
Reviewed-on: https://review.typo3.org/56139
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Alexander Schnitzler <typo3@alexanderschnitzler.de>
Tested-by: Alexander Schnitzler <typo3@alexanderschnitzler.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/core/Classes/Database/QueryGenerator.php
typo3/sysext/core/Tests/Functional/Database/QueryGeneratorTest.php

index 4a81935..2bc52c4 100644 (file)
@@ -1592,7 +1592,11 @@ class QueryGenerator
                     $theList .= ',' . $row['uid'];
                 }
                 if ($depth > 1) {
-                    $theList .= $this->getTreeList($row['uid'], $depth - 1, $begin - 1, $permClause);
+                    $theSubList = $this->getTreeList($row['uid'], $depth - 1, $begin - 1, $permClause);
+                    if (!empty($theList) && !empty($theSubList) && ($theSubList[0] !== ',')) {
+                        $theList .= ',';
+                    }
+                    $theList .= $theSubList;
                 }
             }
         }
index e55d549..20a4bee 100644 (file)
@@ -226,8 +226,6 @@ class QueryGeneratorTest extends FunctionalTestCase
      */
     public function getTreeListReturnsListOfPageIdsOfABranchedTreeWithBeginSetToOne(): void
     {
-        $this->markTestSkipped('Test describes a bug in QueryGenerator::getTreeList, thus this test would fail.');
-
         $id = 1;
         $depth = 3;
         $begin = 1;
@@ -238,11 +236,6 @@ class QueryGeneratorTest extends FunctionalTestCase
         $treeList = $queryGenerator->getTreeList($id, $depth, $begin);
 
         static::assertSame('2,3,4,5', $treeList);
-        // --- Expected
-        // +++ Actual
-        // @@ @@
-        // -'2,3,4,5'
-        // +'2,34,5'
     }
 
     /**
@@ -250,8 +243,6 @@ class QueryGeneratorTest extends FunctionalTestCase
      */
     public function getTreeListReturnsListOfPageIdsOfABranchedTreeWithBeginSetToTwo(): void
     {
-        $this->markTestSkipped('Test describes a bug in QueryGenerator::getTreeList, thus this test would fail.');
-
         $id = 1;
         $depth = 3;
         $begin = 2;
@@ -262,10 +253,5 @@ class QueryGeneratorTest extends FunctionalTestCase
         $treeList = $queryGenerator->getTreeList($id, $depth, $begin);
 
         static::assertSame('3,5', $treeList);
-        // --- Expected
-        // +++ Actual
-        // @@ @@
-        // -'3,5'
-        // +'35'
     }
 }