Skip to content

Commit

Permalink
[BUGFIX] User Setup: Check if languages have been configured
Browse files Browse the repository at this point in the history
On a fresh installation of TYPO3, no system languages are configured
which breaks the "User Setup" module. An additional check for
`EXTCONF/lang/availableLanguages` is added to fix the issue.

Resolves: #86970
Related: #86796
Releases: master
Change-Id: I5ac39ce2b3a7705d29844ea1805a304af58d839f
Reviewed-on: https://review.typo3.org/58927
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
  • Loading branch information
andreaskienast authored and liayn committed Nov 22, 2018
1 parent 8025fa9 commit 23b5ff1
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions typo3/sysext/setup/Classes/Controller/SetupModuleController.php
Expand Up @@ -681,20 +681,23 @@ public function renderLanguageSelect()
// Compile the languages dropdown
$langDefault = htmlspecialchars($language->getLL('lang_default'));
$languageOptions[$langDefault] = '<option value=""' . ($backendUser->uc['lang'] === '' ? ' selected="selected"' : '') . '>' . $langDefault . '</option>';
// Traverse the number of languages
$locales = GeneralUtility::makeInstance(Locales::class);
$languages = $locales->getLanguages();
foreach ($languages as $locale => $name) {
if ($locale !== 'default') {
$defaultName = isset($GLOBALS['LOCAL_LANG']['default']['lang_' . $locale]) ? $GLOBALS['LOCAL_LANG']['default']['lang_' . $locale][0]['source'] : $name;
$localizedName = htmlspecialchars($language->getLL('lang_' . $locale));
if ($localizedName === '') {
$localizedName = htmlspecialchars($name);
}
$localLabel = ' - [' . htmlspecialchars($defaultName) . ']';
$available = in_array($locale, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['lang']['availableLanguages'], true) && is_dir(Environment::getLabelsPath() . '/' . $locale);
if ($available) {
$languageOptions[$defaultName] = '<option value="' . $locale . '"' . ($backendUser->uc['lang'] === $locale ? ' selected="selected"' : '') . '>' . $localizedName . $localLabel . '</option>';
if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['lang']['availableLanguages'])) {
// Traverse the number of languages
$locales = GeneralUtility::makeInstance(Locales::class);
$languages = $locales->getLanguages();

foreach ($languages as $locale => $name) {
if ($locale !== 'default') {
$defaultName = isset($GLOBALS['LOCAL_LANG']['default']['lang_' . $locale]) ? $GLOBALS['LOCAL_LANG']['default']['lang_' . $locale][0]['source'] : $name;
$localizedName = htmlspecialchars($language->getLL('lang_' . $locale));
if ($localizedName === '') {
$localizedName = htmlspecialchars($name);
}
$localLabel = ' - [' . htmlspecialchars($defaultName) . ']';
$available = in_array($locale, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['lang']['availableLanguages'], true) && is_dir(Environment::getLabelsPath() . '/' . $locale);
if ($available) {
$languageOptions[$defaultName] = '<option value="' . $locale . '"' . ($backendUser->uc['lang'] === $locale ? ' selected="selected"' : '') . '>' . $localizedName . $localLabel . '</option>';
}
}
}
}
Expand Down

0 comments on commit 23b5ff1

Please sign in to comment.