[TASK] Remove usage of TSFE->sys_page 94/57694/3
authorBenni Mack <benni@typo3.org>
Thu, 26 Jul 2018 18:37:37 +0000 (20:37 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 26 Jul 2018 20:17:07 +0000 (22:17 +0200)
Due to the introduction of Context's, the FrontendRestrictionContainer
does not have a dependency on TSFE->sys_page anymore.

Resolves: #85661
Releases: master
Change-Id: Iea969090da31c81ccd419c87f3b9970b2634cf11
Reviewed-on: https://review.typo3.org/57694
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Resource/AbstractRepository.php
typo3/sysext/core/Classes/Resource/FileRepository.php
typo3/sysext/core/Classes/Resource/StorageRepository.php
typo3/sysext/core/Tests/Unit/Database/Query/Restriction/FrontendRestrictionContainerTest.php
typo3/sysext/extbase/Classes/Persistence/Generic/Storage/Typo3DbQueryParser.php

index c6fe2e1..9317dfb 100644 (file)
@@ -200,7 +200,7 @@ abstract class AbstractRepository implements RepositoryInterface, SingletonInter
             throw new \InvalidArgumentException('The UID has to be an integer. UID given: "' . $uid . '"', 1316779798);
         }
         $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($this->table);
-        if ($this->getEnvironmentMode() === 'FE' && !empty($GLOBALS['TSFE']->sys_page)) {
+        if ($this->getEnvironmentMode() === 'FE') {
             $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
         }
         $row = $queryBuilder
index 54947a8..9c0c338 100644 (file)
@@ -77,7 +77,7 @@ class FileRepository extends AbstractRepository
             );
         }
         $referenceUids = [];
-        if ($this->getEnvironmentMode() === 'FE' && !empty($GLOBALS['TSFE']->sys_page)) {
+        if ($this->getEnvironmentMode() === 'FE') {
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
                 ->getQueryBuilderForTable('sys_file_reference');
 
index be9bdb3..3f552b9 100644 (file)
@@ -77,7 +77,7 @@ class StorageRepository extends AbstractRepository implements LoggerAwareInterfa
             $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
                 ->getQueryBuilderForTable($this->table);
 
-            if ($this->getEnvironmentMode() === 'FE' && !empty($GLOBALS['TSFE']->sys_page)) {
+            if ($this->getEnvironmentMode() === 'FE') {
                 $queryBuilder->setRestrictions(GeneralUtility::makeInstance(FrontendRestrictionContainer::class));
             }
 
index 7109406..933c134 100644 (file)
@@ -22,7 +22,6 @@ use TYPO3\CMS\Core\Context\WorkspaceAspect;
 use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
-use TYPO3\CMS\Frontend\Page\PageRepository;
 
 class FrontendRestrictionContainerTest extends AbstractRestrictionTestCase
 {
@@ -175,12 +174,6 @@ class FrontendRestrictionContainerTest extends AbstractRestrictionTestCase
         ]);
         GeneralUtility::setSingletonInstance(Context::class, $context);
 
-        $pageRepository = $this->createMock(PageRepository::class);
-        $pageRepository->__set('context', $context);
-        $pageRepository->versioningWorkspaceId = $workspaceId;
-
-        $GLOBALS['TSFE'] = new \stdClass();
-        $GLOBALS['TSFE']->sys_page = $pageRepository;
         $GLOBALS['SIM_ACCESS_TIME'] = 42;
 
         $subject = new FrontendRestrictionContainer($context);
index 0825e89..7fa873f 100644 (file)
@@ -35,7 +35,6 @@ use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
 use TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\BadConstraintException;
 use TYPO3\CMS\Extbase\Persistence\QueryInterface;
 use TYPO3\CMS\Extbase\Service\EnvironmentService;
-use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\Frontend\Page\PageRepository;
 
 /**
@@ -1080,21 +1079,8 @@ class Typo3DbQueryParser
     protected function getPageRepository()
     {
         if (!$this->pageRepository instanceof PageRepository) {
-            if ($this->environmentService->isEnvironmentInFrontendMode() && is_object($this->getTSFE())) {
-                $this->pageRepository = $this->getTSFE()->sys_page;
-            } else {
-                $this->pageRepository = GeneralUtility::makeInstance(PageRepository::class);
-            }
+            $this->pageRepository = GeneralUtility::makeInstance(PageRepository::class);
         }
-
         return $this->pageRepository;
     }
-
-    /**
-     * @return TypoScriptFrontendController|null
-     */
-    protected function getTSFE()
-    {
-        return $GLOBALS['TSFE'] ?? null;
-    }
 }