@@ -2246,7 +2242,7 @@ class EditDocumentController
* hidden. If set to another value, the query will select all sys_language records that has a
* translation record on that page (and is not hidden, unless you are admin user)
* @param string $table For pages we want all languages, for other records the languages of the page translations
- * @return SiteLanguage[] Language
+ * @return array Array with languages (uid, title, ISOcode, flagIcon)
*/
protected function getLanguages(int $id, string $table): array
{
@@ -2266,14 +2262,13 @@ class EditDocumentController
}
$pageId = $id;
}
- try {
- $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByPageId($pageId);
- } catch (SiteNotFoundException $e) {
- $site = new NullSite();
- }
-
// Fetch the current translations of this page, to only show the ones where there is a page translation
- $allLanguages = $site->getAvailableLanguages($this->getBackendUser(), false, $pageId);
+ $allLanguages = array_filter(
+ GeneralUtility::makeInstance(TranslationConfigurationProvider::class)->getSystemLanguages($pageId),
+ static function (array $language): bool {
+ return (int)$language['uid'] !== -1;
+ }
+ );
if ($pageId === 0) {
// Used for e.g. filelist, where there is no site selected
// This also means that there is no "-1" (All Languages) selectable.
$sites = $siteFinder->getAllSites();
foreach ($sites as $site) {
$allSystemLanguages = $this->addSiteLanguagesToConsolidatedList(
$allSystemLanguages,
$site->getAvailableLanguages($this->getBackendUserAuthentication()),
$site,
true
);
}
} else {
try {
$site = $siteFinder->getSiteByPageId((int)$pageId);
} catch (SiteNotFoundException $e) {
$site = new NullSite();
}
$siteLanguages = $site->getAvailableLanguages($this->getBackendUserAuthentication(), true);
if (!isset($siteLanguages[0])) {
$siteLanguages[0] = $site->getDefaultLanguage();
}
$allSystemLanguages = $this->addSiteLanguagesToConsolidatedList(
$allSystemLanguages,
$siteLanguages,
$site,
false
);
}
Outside of a valid page tree, no languages are available, except if we are on page 0. Now this should probably be the same behaviour for the NullSite as well (at least IMHO, since anything else would break previous behaviour, even though the previous version was the buggy behaviour to begin with).
I'm willing to provide a patch for both possibilities, if there is interest and this is really not the intended behaviour, if it turns out that this works as intended and my workflow is wrong, I'll keep the patch for myself :-)