[TASK] Replace SiteMatcher with SiteFinder where applicable 43/61043/2
authorBenni Mack <benni@typo3.org>
Fri, 14 Jun 2019 21:27:13 +0000 (23:27 +0200)
committerBenjamin Franzke <bfr@qbus.de>
Mon, 17 Jun 2019 13:42:55 +0000 (15:42 +0200)
SiteMatcher is a container around SiteFinder now as PseudoSite
handling was removed, so SiteFinder can be used directly.

Resolves: #88568
Releases: master
Change-Id: Ib0f5a42351ed5c11c25458b74074b80f5c574bbd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61043
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Benjamin Franzke <bfr@qbus.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Benjamin Franzke <bfr@qbus.de>
15 files changed:
typo3/sysext/backend/Classes/Configuration/TranslationConfigurationProvider.php
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/backend/Classes/Form/FormDataProvider/SiteResolving.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/SiteResolvingTest.php
typo3/sysext/core/Classes/Hooks/SiteDataHandlerCacheHook.php [deleted file]
typo3/sysext/core/Classes/Routing/PageRouter.php
typo3/sysext/core/ext_localconf.php
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/DataProcessing/LanguageMenuProcessor.php
typo3/sysext/frontend/Classes/DataProcessing/MenuProcessor.php
typo3/sysext/frontend/Classes/DataProcessing/SiteProcessor.php
typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php
typo3/sysext/frontend/Tests/Unit/DataProcessing/SiteProcessorTest.php
typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php

index 649ff1f..8d17b92 100644 (file)
@@ -20,7 +20,9 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
+use TYPO3\CMS\Core\Exception\SiteNotFoundException;
+use TYPO3\CMS\Core\Site\Entity\NullSite;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -39,8 +41,12 @@ class TranslationConfigurationProvider
      */
     public function getSystemLanguages($pageId = 0)
     {
-        $siteMatcher = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId((int)$pageId);
-        $siteLanguages = $siteMatcher->getAvailableLanguages($this->getBackendUserAuthentication(), true);
+        try {
+            $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId((int)$pageId);
+        } catch (SiteNotFoundException $e) {
+            $site = new NullSite();
+        }
+        $siteLanguages = $site->getAvailableLanguages($this->getBackendUserAuthentication(), true);
 
         $languages = [];
         foreach ($siteLanguages as $id => $siteLanguage) {
index b1fc2c7..ac47e43 100644 (file)
@@ -34,14 +34,16 @@ use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
 use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
+use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Http\RedirectResponse;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Page\PageRenderer;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
+use TYPO3\CMS\Core\Site\Entity\NullSite;
 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\HttpUtility;
@@ -2169,7 +2171,11 @@ class EditDocumentController
             }
             $pageId = $id;
         }
-        $site = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId($pageId);
+        try {
+            $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($pageId);
+        } catch (SiteNotFoundException $e) {
+            $site = new NullSite();
+        }
 
         // Fetch the current translations of this page, to only show the ones where there is a page translation
         $allLanguages = $site->getAvailableLanguages($this->getBackendUser(), false, $pageId);
index c9c6caf..f08b336 100644 (file)
@@ -16,7 +16,10 @@ namespace TYPO3\CMS\Backend\Form\FormDataProvider;
  */
 
 use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
+use TYPO3\CMS\Core\Exception\SiteNotFoundException;
+use TYPO3\CMS\Core\Site\Entity\NullSite;
+use TYPO3\CMS\Core\Site\Entity\SiteInterface;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -28,6 +31,13 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  */
 class SiteResolving implements FormDataProviderInterface
 {
+    protected $siteFinder;
+
+    public function __construct(SiteFinder $siteFinder = null)
+    {
+        $this->siteFinder = $siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class);
+    }
+
     /**
      * Find and add site object
      *
@@ -49,7 +59,20 @@ class SiteResolving implements FormDataProviderInterface
         } else {
             $pageIdDefaultLanguage = $result['effectivePid'];
         }
-        $result['site'] = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId((int)$pageIdDefaultLanguage);
+        $result['site'] = $this->resolveSite((int)$pageIdDefaultLanguage);
         return $result;
     }
+
+    /**
+     * @param int $pageId
+     * @return SiteInterface
+     */
+    protected function resolveSite(int $pageId): SiteInterface
+    {
+        try {
+            return $this->siteFinder->getSiteByPageId($pageId);
+        } catch (SiteNotFoundException $e) {
+            return new NullSite();
+        }
+    }
 }
index 6915185..d92b0e3 100644 (file)
@@ -38,10 +38,11 @@ use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Page\PageRenderer;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
 use TYPO3\CMS\Core\Service\DependencyOrderingService;
 use TYPO3\CMS\Core\Service\FlexFormService;
+use TYPO3\CMS\Core\Site\Entity\NullSite;
 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -4294,7 +4295,11 @@ class PageLayoutView implements LoggerAwareInterface
      */
     protected function resolveSiteLanguages(int $pageId)
     {
-        $site = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId($pageId);
+        try {
+            $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($pageId);
+        } catch (SiteNotFoundException $e) {
+            $site = new NullSite();
+        }
         $this->siteLanguages = $site->getAvailableLanguages($this->getBackendUser(), false, $pageId);
     }
 
index df12fbe..df9c800 100644 (file)
@@ -16,9 +16,8 @@ namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
  */
 
 use TYPO3\CMS\Backend\Form\FormDataProvider\SiteResolving;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
 use TYPO3\CMS\Core\Site\Entity\Site;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -33,11 +32,10 @@ class SiteResolvingTest extends UnitTestCase
      */
     public function addDataAddsSiteObjectOfDefaultLanguageRow()
     {
-        $siteMatcherProphecy = $this->prophesize(SiteMatcher::class);
-        GeneralUtility::setSingletonInstance(SiteMatcher::class, $siteMatcherProphecy->reveal());
+        $siteFinderProphecy = $this->prophesize(SiteFinder::class);
         $siteProphecy = $this->prophesize(Site::class);
         $siteProphecyRevelation = $siteProphecy->reveal();
-        $siteMatcherProphecy->matchByPageId(23)->willReturn($siteProphecyRevelation);
+        $siteFinderProphecy->getSiteByPageId(23)->willReturn($siteProphecyRevelation);
         $input = [
             'defaultLanguagePageRow' => [
                 'uid' => 23,
@@ -47,7 +45,7 @@ class SiteResolvingTest extends UnitTestCase
         ];
         $expected = $input;
         $expected['site'] = $siteProphecy->reveal();
-        $this->assertSame($expected, (new SiteResolving())->addData($input));
+        $this->assertSame($expected, (new SiteResolving($siteFinderProphecy->reveal()))->addData($input));
     }
 
     /**
@@ -55,17 +53,16 @@ class SiteResolvingTest extends UnitTestCase
      */
     public function addDataAddsSiteObjectOfEffectivePid()
     {
-        $siteMatcherProphecy = $this->prophesize(SiteMatcher::class);
-        GeneralUtility::setSingletonInstance(SiteMatcher::class, $siteMatcherProphecy->reveal());
+        $siteFinderProphecy = $this->prophesize(SiteFinder::class);
         $siteProphecy = $this->prophesize(Site::class);
         $siteProphecyRevelation = $siteProphecy->reveal();
-        $siteMatcherProphecy->matchByPageId(42)->willReturn($siteProphecyRevelation);
+        $siteFinderProphecy->getSiteByPageId(42)->willReturn($siteProphecyRevelation);
         $input = [
             'effectivePid' => 42,
             'site' => $siteProphecyRevelation,
         ];
         $expected = $input;
         $expected['site'] = $siteProphecy->reveal();
-        $this->assertSame($expected, (new SiteResolving())->addData($input));
+        $this->assertSame($expected, (new SiteResolving($siteFinderProphecy->reveal()))->addData($input));
     }
 }
diff --git a/typo3/sysext/core/Classes/Hooks/SiteDataHandlerCacheHook.php b/typo3/sysext/core/Classes/Hooks/SiteDataHandlerCacheHook.php
deleted file mode 100644 (file)
index e526e61..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-declare(strict_types = 1);
-
-namespace TYPO3\CMS\Core\Hooks;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Core\Cache\CacheManager;
-use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
-use TYPO3\CMS\Core\DataHandling\DataHandler;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
-
-/**
- * When a sys_domain or sys_language record is modified, the Site Handling caches should be flushed.
- * Also, if pages on root level are changed, site handling caches need flush.
- *
- * @internal This class is a hook implementation and is not part of the TYPO3 Core API.
- */
-class SiteDataHandlerCacheHook
-{
-    /**
-     * Called after a record was edited or added.
-     *
-     * @param string $status DataHandler operation status, either 'new' or 'update'
-     * @param string $table The DB table the operation was carried out on
-     * @param mixed $recordId The record's uid for update records, a string to look the record's uid up after it has been created
-     * @param array $updatedFields Array of changed fields and their new values
-     * @param DataHandler $dataHandler DataHandler parent object
-     */
-    public function processDatamap_afterDatabaseOperations(string $status, string $table, $recordId, array $updatedFields, DataHandler $dataHandler)
-    {
-        if ($table === 'sys_language'
-            || ($status === 'new' && $table === 'pages' && (int)$updatedFields['pid'] === 0)
-        ) {
-            $this->getCache()->remove('pseudo-sites');
-            // After evicting caches, we need to make sure these are re-initialized within the
-            // current request if needed. Easiest solution is to purge the SiteMatcher singleton.
-            GeneralUtility::removeSingletonInstance(SiteMatcher::class, GeneralUtility::makeInstance(SiteMatcher::class));
-        }
-    }
-
-    /**
-     * Called after a record was deleted, moved or restored.
-     *
-     * @param string $command the cmd which was executed
-     * @param string $table The DB table the operation was carried out on
-     * @param mixed $id the ID which was operated on
-     * @param mixed $value
-     * @param DataHandler $dataHandler
-     * @param mixed $pasteUpdate
-     * @param array $pasteDatamap
-     */
-    public function processCmdmap_postProcess(string $command, string $table, $id, $value, DataHandler $dataHandler, $pasteUpdate, array $pasteDatamap)
-    {
-        if ($table === 'sys_language') {
-            $this->getCache()->remove('pseudo-sites');
-        }
-    }
-
-    /**
-     * Shorthand method to flush the related caches
-     * @return FrontendInterface
-     * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
-     */
-    protected function getCache(): FrontendInterface
-    {
-        return GeneralUtility::makeInstance(CacheManager::class)->getCache('core');
-    }
-}
index c247df9..8c1bd8b 100644 (file)
@@ -41,6 +41,7 @@ use TYPO3\CMS\Core\Routing\Enhancer\ResultingInterface;
 use TYPO3\CMS\Core\Routing\Enhancer\RoutingEnhancerInterface;
 use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Page\CacheHashCalculator;
 use TYPO3\CMS\Frontend\Page\PageRepository;
@@ -386,13 +387,13 @@ class PageRouter implements RouterInterface
             ->execute();
 
         $pages = [];
-        $siteMatcher = GeneralUtility::makeInstance(SiteMatcher::class);
+        $siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
         $pageRepository = GeneralUtility::makeInstance(PageRepository::class, $context);
         while ($row = $statement->fetch()) {
             $pageRepository->fixVersioningPid('pages', $row);
             $pageIdInDefaultLanguage = (int)($languageId > 0 ? $row['l10n_parent'] : $row['uid']);
             try {
-                if ($siteMatcher->matchByPageId($pageIdInDefaultLanguage)->getRootPageId() === $this->site->getRootPageId()) {
+                if ($siteFinder->getSiteByPageId($pageIdInDefaultLanguage)->getRootPageId() === $this->site->getRootPageId()) {
                     $pages[] = $row;
                 }
             } catch (SiteNotFoundException $e) {
index 4339e0b..cb34301 100644 (file)
@@ -27,11 +27,6 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['proc
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/alt_doc.php']['makeEditForm_accessCheck'][] = \TYPO3\CMS\Core\Resource\Security\FileMetadataPermissionsAspect::class . '->isAllowedToShowEditForm';
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms_inline.php']['checkAccess'][] = \TYPO3\CMS\Core\Resource\Security\FileMetadataPermissionsAspect::class . '->isAllowedToShowEditForm';
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkModifyAccessList'][] = \TYPO3\CMS\Core\Resource\Security\FileMetadataPermissionsAspect::class;
-
-// Registering hooks for the Site Cache Hook
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = \TYPO3\CMS\Core\Hooks\SiteDataHandlerCacheHook::class;
-$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = \TYPO3\CMS\Core\Hooks\SiteDataHandlerCacheHook::class;
-
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = \TYPO3\CMS\Core\Hooks\DestroySessionHook::class;
 
 $signalSlotDispatcher->connect(
index 228536e..9d406b8 100644 (file)
@@ -19,8 +19,10 @@ use TYPO3\CMS\Core\Context\Context;
 use TYPO3\CMS\Core\Context\LanguageAspect;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\RelationHandler;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
+use TYPO3\CMS\Core\Exception\SiteNotFoundException;
+use TYPO3\CMS\Core\Site\Entity\NullSite;
 use TYPO3\CMS\Core\Site\Entity\SiteInterface;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\TypoScript\TypoScriptService;
@@ -2120,12 +2122,15 @@ abstract class AbstractMenuContentObject
      * Returns the currently configured "site" if a site is configured (= resolved) in the current request.
      *
      * @return SiteInterface
-     * @throws \TYPO3\CMS\Core\Exception\SiteNotFoundException
      */
     protected function getCurrentSite(): SiteInterface
     {
-        $matcher = GeneralUtility::makeInstance(SiteMatcher::class);
-        return $matcher->matchByPageId((int)$this->getTypoScriptFrontendController()->id);
+        try {
+            return GeneralUtility::makeInstance(SiteFinder::class)
+                ->getSiteByPageId((int)$this->getTypoScriptFrontendController()->id);
+        } catch (SiteNotFoundException $e) {
+            return new NullSite();
+        }
     }
 
     /**
index 6c3f3ad..5c25f54 100644 (file)
@@ -16,8 +16,10 @@ namespace TYPO3\CMS\Frontend\DataProcessing;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Routing\SiteMatcher;
+use TYPO3\CMS\Core\Exception\SiteNotFoundException;
+use TYPO3\CMS\Core\Site\Entity\NullSite;
 use TYPO3\CMS\Core\Site\Entity\SiteInterface;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
@@ -272,12 +274,15 @@ class LanguageMenuProcessor implements DataProcessorInterface
      * Returns the currently configured "site" if a site is configured (= resolved) in the current request.
      *
      * @return SiteInterface
-     * @throws \TYPO3\CMS\Core\Exception\SiteNotFoundException
      */
     protected function getCurrentSite(): SiteInterface
     {
-        $matcher = GeneralUtility::makeInstance(SiteMatcher::class);
-        return $matcher->matchByPageId((int)$this->getTypoScriptFrontendController()->id);
+        try {
+            return GeneralUtility::makeInstance(SiteFinder::class)
+                ->getSiteByPageId((int)$this->getTypoScriptFrontendController()->id);
+        } catch (SiteNotFoundException $e) {
+            return new NullSite();
+        }
     }
 
     /**
index ccb8ec9..4ede1b5 100644 (file)
@@ -14,8 +14,10 @@ namespace TYPO3\CMS\Frontend\DataProcessing;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Routing\SiteMatcher;
+use TYPO3\CMS\Core\Exception\SiteNotFoundException;
+use TYPO3\CMS\Core\Site\Entity\NullSite;
 use TYPO3\CMS\Core\Site\Entity\SiteInterface;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentDataProcessor;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
@@ -531,12 +533,15 @@ class MenuProcessor implements DataProcessorInterface
      * Returns the currently configured "site" if a site is configured (= resolved) in the current request.
      *
      * @return SiteInterface
-     * @throws \TYPO3\CMS\Core\Exception\SiteNotFoundException
      */
     protected function getCurrentSite(): SiteInterface
     {
-        $matcher = GeneralUtility::makeInstance(SiteMatcher::class);
-        return $matcher->matchByPageId((int)$this->getTypoScriptFrontendController()->id);
+        try {
+            return GeneralUtility::makeInstance(SiteFinder::class)
+                ->getSiteByPageId((int)$this->getTypoScriptFrontendController()->id);
+        } catch (SiteNotFoundException $e) {
+            return new NullSite();
+        }
     }
 
     /**
index 17b47b1..3d8e85f 100644 (file)
@@ -16,8 +16,8 @@ namespace TYPO3\CMS\Frontend\DataProcessing;
  */
 
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
 use TYPO3\CMS\Core\Site\Entity\SiteInterface;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
@@ -59,7 +59,7 @@ class SiteProcessor implements DataProcessorInterface
     protected function getCurrentSite(): ?SiteInterface
     {
         try {
-            return $this->getMatcher()->matchByPageId($this->getCurrentPageId());
+            return $this->getSiteFinder()->getSiteByPageId($this->getCurrentPageId());
         } catch (SiteNotFoundException $e) {
             // Do nothing
         }
@@ -68,11 +68,11 @@ class SiteProcessor implements DataProcessorInterface
     }
 
     /**
-     * @return SiteMatcher
+     * @return SiteFinder
      */
-    protected function getMatcher(): SiteMatcher
+    protected function getSiteFinder(): SiteFinder
     {
-        return GeneralUtility::makeInstance(SiteMatcher::class);
+        return GeneralUtility::makeInstance(SiteFinder::class);
     }
 
     /**
index 5003dc4..26a8d52 100644 (file)
@@ -27,7 +27,6 @@ use TYPO3\CMS\Core\Exception\Page\RootLineException;
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
 use TYPO3\CMS\Core\Routing\InvalidRouteArgumentsException;
 use TYPO3\CMS\Core\Routing\RouterInterface;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
 use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\CMS\Core\Site\Entity\SiteInterface;
 use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
@@ -616,9 +615,9 @@ class PageLinkBuilder extends AbstractTypolinkBuilder
             return $GLOBALS['TYPO3_REQUEST']->getAttribute('site', null);
         }
         if (MathUtility::canBeInterpretedAsInteger($GLOBALS['TSFE']->id) && $GLOBALS['TSFE']->id > 0) {
-            $matcher = GeneralUtility::makeInstance(SiteMatcher::class);
+            $finder = GeneralUtility::makeInstance(SiteFinder::class);
             try {
-                $site = $matcher->matchByPageId((int)$GLOBALS['TSFE']->id);
+                $site = $finder->getSiteByPageId((int)$GLOBALS['TSFE']->id);
             } catch (SiteNotFoundException $e) {
                 $site = null;
             }
index e821ec8..e2cffe2 100644 (file)
@@ -17,8 +17,8 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\DataProcessing;
  */
 
 use TYPO3\CMS\Core\Exception\SiteNotFoundException;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
 use TYPO3\CMS\Core\Site\Entity\Site;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\DataProcessing\SiteProcessor;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
@@ -57,11 +57,11 @@ class SiteProcessorTest extends UnitTestCase
         $mockedContentObjectRenderer = $this->getAccessibleMock(ContentObjectRenderer::class, ['stdWrapValue'], [], '', false);
         $mockedContentObjectRenderer->expects($this->any())->method('stdWrapValue')->with('as', $processorConfiguration, 'site')->willReturn('variable');
 
-        $matcherMock = $this->getMockBuilder(SiteMatcher::class)->disableOriginalConstructor()->getMock();
-        $matcherMock->expects($this->any())->method('matchByPageId')->willThrowException(new SiteNotFoundException('message', 1550670118));
+        $finderMock = $this->getMockBuilder(SiteFinder::class)->disableOriginalConstructor()->getMock();
+        $finderMock->expects($this->any())->method('getSiteByPageId')->willThrowException(new SiteNotFoundException('message', 1550670118));
 
         $subject = $this->getAccessibleMock(SiteProcessor::class, ['getMatcher', 'getCurrentPageId'], []);
-        $subject->expects($this->any())->method('getMatcher')->willReturn($matcherMock);
+        $subject->expects($this->any())->method('getSiteFinder')->willReturn($finderMock);
         $subject->expects($this->any())->method('getCurrentPageId')->willReturn(1);
 
         $processedData = $subject->process($mockedContentObjectRenderer, [], $processorConfiguration, []);
index 54e008c..07e0a9b 100644 (file)
@@ -31,8 +31,9 @@ use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
 use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Routing\InvalidRouteArgumentsException;
-use TYPO3\CMS\Core\Routing\SiteMatcher;
+use TYPO3\CMS\Core\Site\Entity\NullSite;
 use TYPO3\CMS\Core\Site\Entity\Site;
+use TYPO3\CMS\Core\Site\SiteFinder;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
@@ -223,11 +224,11 @@ class ViewModuleController
             // Mount point overlay: Set new target page id and mp parameter
             $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
             $additionalGetVars = $this->getAdminCommand($pageId);
-            $siteMatcher = GeneralUtility::makeInstance(SiteMatcher::class);
+            $siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
             try {
-                $site = $siteMatcher->matchByPageId($pageId, $rootLine);
+                $site = $siteFinder->getSiteByPageId($pageId, $rootLine);
             } catch (SiteNotFoundException $e) {
-                $site = null;
+                $site = new NullSite();
             }
             $finalPageIdToShow = $pageId;
             $mountPointInformation = $pageRepository->getMountPointInfo($pageId);
@@ -359,7 +360,7 @@ class ViewModuleController
 
         try {
             $pageRepository = GeneralUtility::makeInstance(PageRepository::class);
-            $site = GeneralUtility::makeInstance(SiteMatcher::class)->matchByPageId($pageId);
+            $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($pageId);
             $siteLanguages = $site->getAvailableLanguages($this->getBackendUser(), false, $pageId);
 
             foreach ($siteLanguages as $siteLanguage) {