#99530Function getDefaultLanguage returns disabled language
Description
Function TYPO3\CMS\Core\Site\Entity\Site->getDefaultLanguage() (https://github.com/TYPO3/typo3/blob/10.4/typo3/sysext/core/Classes/Site/Entity/Site.php#L255) returns disabled languages. This comes into case when requesting a not existing page, e.g. www.mysite.tld/de_INT/not-existing/. Error handling now tries to resolve requested language (here: https://github.com/TYPO3/typo3/blob/10.4/typo3/sysext/core/Classes/Error/PageErrorHandler/PageContentErrorHandler.php#L210) and this is the disabled language “de_INT”.
My site config is:
languages:
-
title: de_INT
enabled: false
languageId: '0'
...
-
title: en_INT
enabled: true
languageId: '1'
...
Function getDefaultLanguage() doesn’t respect not enabled languages, so it returns de_INT, but should return en_INT.
This should fix it:
public function getDefaultLanguage(): SiteLanguage {
$siteLanguages = $this->getLanguages();
return = array_values($siteLanguages)[0];
}