[TASK] Make $permClause parameter optional in QueryGenerator 85/53585/2
authorMarkus Hoelzle <typo3@markus-hoelzle.de>
Tue, 25 Jul 2017 14:11:16 +0000 (16:11 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Sun, 30 Jul 2017 18:21:45 +0000 (20:21 +0200)
The 3rd parameter is optional, so the 4th parameter should be
optional too.

Resolves: #81965
Releases: master
Change-Id: I4240824717a0a18c0aa669ef891ce3b42b2fbc7c
Reviewed-on: https://review.typo3.org/53585
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/core/Classes/Database/QueryGenerator.php

index 30eac16..52e92a4 100644 (file)
@@ -1541,7 +1541,7 @@ class QueryGenerator
      * @param string $permClause
      * @return string
      */
-    public function getTreeList($id, $depth, $begin = 0, $permClause)
+    public function getTreeList($id, $depth, $begin = 0, $permClause = '')
     {
         $depth = (int)$depth;
         $begin = (int)$begin;
@@ -1557,13 +1557,13 @@ class QueryGenerator
         if ($id && $depth > 0) {
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
             $queryBuilder->getRestrictions()->removeAll()->add(GeneralUtility::makeInstance(DeletedRestriction::class));
-            $statement = $queryBuilder->select('uid')
+            $queryBuilder->select('uid')
                 ->from('pages')
-                ->where(
-                    $queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)),
-                    QueryHelper::stripLogicalOperatorPrefix($permClause)
-                )
-                ->execute();
+                ->where($queryBuilder->expr()->eq('pid', $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)));
+            if ($permClause !== '') {
+                $queryBuilder->andWhere(QueryHelper::stripLogicalOperatorPrefix($permClause));
+            }
+            $statement = $queryBuilder->execute();
             while ($row = $statement->fetch()) {
                 if ($begin <= 0) {
                     $theList .= ',' . $row['uid'];