[BUGFIX] Transform language parameter when previewing translated pages 38/58438/3
authorOliver Hader <oliver@typo3.org>
Fri, 28 Sep 2018 16:35:40 +0000 (18:35 +0200)
committerBenni Mack <benni@typo3.org>
Fri, 28 Sep 2018 19:27:18 +0000 (21:27 +0200)
When previewing translated pages in the backend, URLs contain `&L=x` at
the end. This is due to a missing transformation into the `_language`
parameter as well a missing SiteLanguage resolving.

Resolves: #86421
Releases: master
Change-Id: I5da496d0224635b1ee849dd7a724145ad2c0d408
Reviewed-on: https://review.typo3.org/58438
Reviewed-by: Richard Haeser <richard@maxserv.com>
Tested-by: Richard Haeser <richard@maxserv.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/Routing/PageRouter.php

index 0ae30bc..29d713d 100644 (file)
@@ -2671,6 +2671,10 @@ class BackendUtility
                 // Create a multi-dimensional array out of the additional get vars
                 $additionalQueryParams = [];
                 parse_str($additionalGetVars, $additionalQueryParams);
+                if (isset($additionalQueryParams['L'])) {
+                    $additionalQueryParams['_language'] = $additionalQueryParams['_language'] ?? $additionalQueryParams['L'];
+                    unset($additionalQueryParams['L']);
+                }
                 $previewUrl = (string)$site->getRouter()->generateUri(
                     $pageUid,
                     $additionalQueryParams,
index d9d9a84..d005de9 100644 (file)
@@ -135,9 +135,11 @@ class PageRouter implements RouterInterface
         // Resolve language
         $language = null;
         $languageOption = $parameters['_language'] ?? null;
+        unset($parameters['_language']);
         if ($languageOption instanceof SiteLanguage) {
             $language = $languageOption;
-            unset($parameters['_language']);
+        } elseif ($languageOption !== null) {
+            $language = $this->site->getLanguageById((int)$languageOption);
         }
         if ($language === null) {
             $language = $this->site->getDefaultLanguage();