diff --git a/Classes/Domain/Site/SiteHashService.php b/Classes/Domain/Site/SiteHashService.php index 0da68d33b..c9b866733 100644 --- a/Classes/Domain/Site/SiteHashService.php +++ b/Classes/Domain/Site/SiteHashService.php @@ -19,6 +19,7 @@ use Doctrine\DBAL\Driver\Exception as DBALDriverException; use Throwable; +use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -77,20 +78,19 @@ public function getSiteHashForDomain(string $domain): string } /** - * Returns a comma separated list of all domains from all sites. + * Returns a comma separated list with domains of all sites. * * @return string - * @throws DBALDriverException * @throws Throwable */ protected function getDomainListOfAllSites(): string { - $sites = $this->getAvailableSites(); + $siteFinder = GeneralUtility::makeInstance(SiteFinder::class); + $sites = $siteFinder->getAllSites(); $domains = []; foreach ($sites as $site) { - $domains[] = $site->getDomain(); + $domains[] = $site->getBase()->getHost(); } - return implode(',', $domains); } diff --git a/Tests/Unit/Domain/Site/SiteHashServiceTest.php b/Tests/Unit/Domain/Site/SiteHashServiceTest.php index 215ddc6c3..4f18aa2b8 100644 --- a/Tests/Unit/Domain/Site/SiteHashServiceTest.php +++ b/Tests/Unit/Domain/Site/SiteHashServiceTest.php @@ -53,9 +53,11 @@ public function canResolveSiteHashAllowedSites($allowedSitesConfiguration, $expe $siteB = $this->getDumbMock(Site::class); $siteB->expects(self::any())->method('getDomain')->willReturn('solrtestb.local'); $allSites = [$siteA, $siteB]; + $allSitesString = ('solrtesta.local,solrtestb.local'); /** @var $siteHashServiceMock SiteHashService */ - $siteHashServiceMock = $this->getMockBuilder(SiteHashService::class)->onlyMethods(['getAvailableSites', 'getSiteByPageId'])->getMock(); + $siteHashServiceMock = $this->getMockBuilder(SiteHashService::class)->onlyMethods(['getDomainListOfAllSites', 'getAvailableSites', 'getSiteByPageId'])->getMock(); + $siteHashServiceMock->expects(self::any())->method('getDomainListOfAllSites')->willReturn($allSitesString); $siteHashServiceMock->expects(self::any())->method('getAvailableSites')->willReturn($allSites); $siteHashServiceMock->expects(self::any())->method('getSiteByPageId')->willReturn($siteA);