Project

General

Profile

Actions

Bug #99530

closed

Function getDefaultLanguage returns disabled language

Added by Sven Burkert over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2023-01-13
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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];
}

Actions

Also available in: Atom PDF