diff --git a/Classes/System/Util/SiteUtility.php b/Classes/System/Util/SiteUtility.php index c655b9acc..7c9c7188e 100644 --- a/Classes/System/Util/SiteUtility.php +++ b/Classes/System/Util/SiteUtility.php @@ -37,6 +37,9 @@ class SiteUtility { + /** @var array */ + public static $languages = []; + /** * Determines if the site where the page belongs to is managed with the TYPO3 site management. * @@ -111,8 +114,10 @@ protected static function getConnectionPropertyOrFallback(Site $typo3Site, strin $fallbackKey = 'solr_' . $property . '_read'; // try to find language specific setting if found return it - $languageSpecificConfiguration = $typo3Site->getLanguageById($languageId)->toArray(); - $value = self::getValueOrFallback($languageSpecificConfiguration, $keyToCheck, $fallbackKey); + if (isset(self::$languages[$languageId]) === false) { + self::$languages[$languageId] = $typo3Site->getLanguageById($languageId)->toArray(); + } + $value = self::getValueOrFallback(self::$languages[$languageId], $keyToCheck, $fallbackKey); if ($value !== null) { return $value; } @@ -132,8 +137,10 @@ protected static function getConnectionPropertyOrFallback(Site $typo3Site, strin */ protected static function writeConnectionIsEnabled(Site $typo3Site, int $languageId): bool { - $languageSpecificConfiguration = $typo3Site->getLanguageById($languageId)->toArray(); - $value = self::getValueOrFallback($languageSpecificConfiguration, 'solr_use_write_connection', 'solr_use_write_connection'); + if (isset(self::$languages[$languageId]) === false) { + self::$languages[$languageId] = $typo3Site->getLanguageById($languageId)->toArray(); + } + $value = self::getValueOrFallback(self::$languages[$languageId], 'solr_use_write_connection', 'solr_use_write_connection'); if ($value !== null) { return $value; } diff --git a/Tests/Unit/System/Util/SiteUtilityTest.php b/Tests/Unit/System/Util/SiteUtilityTest.php index ff9bba89e..3d6bd5457 100644 --- a/Tests/Unit/System/Util/SiteUtilityTest.php +++ b/Tests/Unit/System/Util/SiteUtilityTest.php @@ -36,6 +36,11 @@ */ class SiteUtilityTest extends UnitTest { + public function tearDown() + { + SiteUtility::$languages = []; + } + /** * @test */ @@ -286,4 +291,4 @@ public function canHandleSiteConfigurationValues ( $this->assertEquals($expectedConfigurationValue, $property, 'Value from site configuration not read/handled correctly.'); } -} \ No newline at end of file +}