[BUGFIX] BackendUtility should not use PageRepository 27/52627/4
authorBenni Mack <benni@typo3.org>
Thu, 27 Apr 2017 05:07:22 +0000 (07:07 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Fri, 28 Apr 2017 07:40:37 +0000 (09:40 +0200)
BackendUtility builds a PageRepository object to fetch a SQL query instead
of simply using the Deleted+HiddenRestriction themselves to fetch the first fe_group
record.

The PageRepository object does not even get initialized, so it can safely be exchanged.

Releases: master
Resolves: #81032
Change-Id: I4279f189c5c42c763aeeb3f519326677e94bd160
Reviewed-on: https://review.typo3.org/52627
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/backend/Classes/Utility/BackendUtility.php

index e7d37fd..f4c25c7 100644 (file)
@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryHelper;
 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
+use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction;
 use TYPO3\CMS\Core\Database\RelationHandler;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
@@ -763,8 +764,6 @@ class BackendUtility
      * Stores $data in the 'cache_hash' cache with the hash key, $hash
      * and visual/symbolic identification, $ident
      *
-     * IDENTICAL to the function by same name found in \TYPO3\CMS\Frontend\Page\PageRepository
-     *
      * @param string $hash 32 bit hash string (eg. a md5 hash of a serialized array identifying the data being stored)
      * @param mixed $data The data to store
      * @param string $ident $ident is just a textual identification in order to inform about the content!
@@ -780,8 +779,6 @@ class BackendUtility
      * Returns data stored for the hash string in the cache "cache_hash"
      * Can be used to retrieved a cached value, array or object
      *
-     * IDENTICAL to the function by same name found in \TYPO3\CMS\Frontend\Page\PageRepository
-     *
      * @param string $hash The hash-string which was used to store the data value
      * @return mixed The "data" from the cache
      */
@@ -4266,21 +4263,16 @@ class BackendUtility
         if ($pageInfo['fe_group'] > 0) {
             $simUser = '&ADMCMD_simUser=' . $pageInfo['fe_group'];
         } elseif ((int)$pageInfo['fe_group'] === -2) {
-            $tableNameFeGroup = 'fe_groups';
-
             // -2 means "show at any login". We simulate first available fe_group.
-            /** @var PageRepository $sysPage */
-            $sysPage = GeneralUtility::makeInstance(PageRepository::class);
-
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
-                ->getQueryBuilderForTable($tableNameFeGroup);
-            $queryBuilder->getRestrictions()->removeAll();
+                ->getQueryBuilderForTable('fe_groups');
+            $queryBuilder->getRestrictions()
+                ->removeAll()
+                ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
+                ->add(GeneralUtility::makeInstance(HiddenRestriction::class));
 
             $activeFeGroupRow = $queryBuilder->select('uid')
-                ->from($tableNameFeGroup)
-                ->where(
-                    QueryHelper::stripLogicalOperatorPrefix('1=1' . $sysPage->enableFields($tableNameFeGroup))
-                )
+                ->from('fe_groups')
                 ->execute()
                 ->fetch();