Skip to content

Commit 398b9e6

Browse files
committed
[BUGFIX] slow response when allowedSites = __all
Fixes: #3292
1 parent df336e1 commit 398b9e6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Classes/Domain/Site/SiteHashService.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
2121
use Throwable;
22+
use TYPO3\CMS\Core\Site\SiteFinder;
2223
use TYPO3\CMS\Core\Utility\GeneralUtility;
2324

2425
/**
@@ -77,20 +78,19 @@ public function getSiteHashForDomain(string $domain): string
7778
}
7879

7980
/**
80-
* Returns a comma separated list of all domains from all sites.
81+
* Returns a comma separated list with domains of all sites.
8182
*
8283
* @return string
83-
* @throws DBALDriverException
8484
* @throws Throwable
8585
*/
8686
protected function getDomainListOfAllSites(): string
8787
{
88-
$sites = $this->getAvailableSites();
88+
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
89+
$sites = $siteFinder->getAllSites();
8990
$domains = [];
9091
foreach ($sites as $site) {
91-
$domains[] = $site->getDomain();
92+
$domains[] = $site->getBase()->getHost();
9293
}
93-
9494
return implode(',', $domains);
9595
}
9696

Tests/Unit/Domain/Site/SiteHashServiceTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,11 @@ public function canResolveSiteHashAllowedSites($allowedSitesConfiguration, $expe
5454
$siteB = $this->getDumbMock(Site::class);
5555
$siteB->expects(self::any())->method('getDomain')->willReturn('solrtestb.local');
5656
$allSites = [$siteA, $siteB];
57+
$allSitesString = implode(',', $allSites);
5758

5859
/** @var $siteHashServiceMock SiteHashService */
59-
$siteHashServiceMock = $this->getMockBuilder(SiteHashService::class)->onlyMethods(['getAvailableSites', 'getSiteByPageId'])->getMock();
60+
$siteHashServiceMock = $this->getMockBuilder(SiteHashService::class)->onlyMethods(['getDomainListOfAllSites', 'getAvailableSites', 'getSiteByPageId'])->getMock();
61+
$siteHashServiceMock->expects(self::any())->method('getDomainListOfAllSites')->willReturn($allSitesString);
6062
$siteHashServiceMock->expects(self::any())->method('getAvailableSites')->willReturn($allSites);
6163
$siteHashServiceMock->expects(self::any())->method('getSiteByPageId')->willReturn($siteA);
6264

0 commit comments

Comments
 (0)