diff --git a/typo3/sysext/backend/Classes/Configuration/TranslationConfigurationProvider.php b/typo3/sysext/backend/Classes/Configuration/TranslationConfigurationProvider.php index 649ff1f27b77e9720358448f37cddbb6a95c3102..8d17b92b5248e348fd4035eb805baa2b6ed994a5 100644 --- a/typo3/sysext/backend/Classes/Configuration/TranslationConfigurationProvider.php +++ b/typo3/sysext/backend/Classes/Configuration/TranslationConfigurationProvider.php @@ -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) { diff --git a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php index b1fc2c7f59768a2dc1988cf4080cfe7c8f776dc2..ac47e439f0cb5d4d238208f62baf9bd531f408b1 100644 --- a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php +++ b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php @@ -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); diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteResolving.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteResolving.php index c9c6caf4b4dbd24dcf4abf65991a6b1b614277bd..f08b336c20829c4bf3ff38b81a4da9228a3d0104 100644 --- a/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteResolving.php +++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/SiteResolving.php @@ -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(); + } + } } diff --git a/typo3/sysext/backend/Classes/View/PageLayoutView.php b/typo3/sysext/backend/Classes/View/PageLayoutView.php index 691518572b530172fc46f613d22e68dd9ecb7620..d92b0e3b6cee41c64da22233a522fd266c6880ab 100644 --- a/typo3/sysext/backend/Classes/View/PageLayoutView.php +++ b/typo3/sysext/backend/Classes/View/PageLayoutView.php @@ -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); } diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/SiteResolvingTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/SiteResolvingTest.php index df12fbe07aacb912e896ecb973847f4fbb3aad34..df9c800fa5715f7dda45861b29f6c3bf5529821c 100644 --- a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/SiteResolvingTest.php +++ b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/SiteResolvingTest.php @@ -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 index e526e613e08472c7be691b3cae77431a2c815388..0000000000000000000000000000000000000000 --- a/typo3/sysext/core/Classes/Hooks/SiteDataHandlerCacheHook.php +++ /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'); - } -} diff --git a/typo3/sysext/core/Classes/Routing/PageRouter.php b/typo3/sysext/core/Classes/Routing/PageRouter.php index c247df943a0629ef8a045fb501682a2687678af8..8c1bd8b4200e6bdb11dcf51f129ce879d30e1f75 100644 --- a/typo3/sysext/core/Classes/Routing/PageRouter.php +++ b/typo3/sysext/core/Classes/Routing/PageRouter.php @@ -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) { diff --git a/typo3/sysext/core/ext_localconf.php b/typo3/sysext/core/ext_localconf.php index 4339e0b1dbcd8cdf19942e1f2452604d140533ac..cb34301421f442f228853c06ae287221744564a2 100644 --- a/typo3/sysext/core/ext_localconf.php +++ b/typo3/sysext/core/ext_localconf.php @@ -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( diff --git a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php index 228536eea02da4c72a06848bc7d01121f995fa10..9d406b813df31063b662ea5cb4414a6af5115bd8 100644 --- a/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php +++ b/typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php @@ -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(); + } } /** diff --git a/typo3/sysext/frontend/Classes/DataProcessing/LanguageMenuProcessor.php b/typo3/sysext/frontend/Classes/DataProcessing/LanguageMenuProcessor.php index 6c3f3ad605776b26053a4494f7cf25cacef2ecdb..5c25f54099b6fcb112731019550a4ac5f111b6b8 100644 --- a/typo3/sysext/frontend/Classes/DataProcessing/LanguageMenuProcessor.php +++ b/typo3/sysext/frontend/Classes/DataProcessing/LanguageMenuProcessor.php @@ -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(); + } } /** diff --git a/typo3/sysext/frontend/Classes/DataProcessing/MenuProcessor.php b/typo3/sysext/frontend/Classes/DataProcessing/MenuProcessor.php index ccb8ec97b082373649491ba26c51a5b1c7d7d2fd..4ede1b5aceef6f3b8846ff247df1a6d6e1f35890 100644 --- a/typo3/sysext/frontend/Classes/DataProcessing/MenuProcessor.php +++ b/typo3/sysext/frontend/Classes/DataProcessing/MenuProcessor.php @@ -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(); + } } /** diff --git a/typo3/sysext/frontend/Classes/DataProcessing/SiteProcessor.php b/typo3/sysext/frontend/Classes/DataProcessing/SiteProcessor.php index 17b47b134e5813f0604668552e2b444ec3c2c182..3d8e85f34fba935d379da70c5e02ea80e8d59a29 100644 --- a/typo3/sysext/frontend/Classes/DataProcessing/SiteProcessor.php +++ b/typo3/sysext/frontend/Classes/DataProcessing/SiteProcessor.php @@ -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); } /** diff --git a/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php b/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php index 5003dc4d230159cef447812b92c68c3154981581..26a8d523a0fdd0f5ce3841f72bd40fd426d84cbe 100644 --- a/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php +++ b/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php @@ -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; } diff --git a/typo3/sysext/frontend/Tests/Unit/DataProcessing/SiteProcessorTest.php b/typo3/sysext/frontend/Tests/Unit/DataProcessing/SiteProcessorTest.php index e821ec8decb7833096eecac295016d0cebebabe1..e2cffe21d6f047b493c128df228b89dc3f0d82b3 100644 --- a/typo3/sysext/frontend/Tests/Unit/DataProcessing/SiteProcessorTest.php +++ b/typo3/sysext/frontend/Tests/Unit/DataProcessing/SiteProcessorTest.php @@ -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, []); diff --git a/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php b/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php index 54e008c7a08299fd03bf67493f75c0dffdb274e8..07e0a9b980d752c631426c6ffd7db99d084e0c7f 100644 --- a/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php +++ b/typo3/sysext/viewpage/Classes/Controller/ViewModuleController.php @@ -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) {