From 4ef07f345f13374969c1273101d99c005342d574 Mon Sep 17 00:00:00 2001 From: Riny van Tiggelen <info@online-gamer.nl> Date: Wed, 23 Nov 2022 18:46:48 +0100 Subject: [PATCH] [BUGFIX] Omit warning when allowInconsistentLanguageHandling is active In case mod.web_layout.allowInconsistentLanguageHandling is set, no warnings about inconsistent language usage should be displayed. This is now properly checked in ContentFetcher, which would otherwise add a warning message to the queue. Resolves: #99171 Releases: main, 12.4 Change-Id: If0f6cce36e5d35e0ec5ca3df865cc5736bb44005 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79853 Tested-by: core-ci <typo3@b13.com> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Benni Mack <benni@typo3.org> --- .../Controller/PageLayoutController.php | 1 + .../View/BackendLayout/ContentFetcher.php | 24 +++++++++++-------- .../View/Drawing/DrawingConfiguration.php | 15 ++++++++++++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php index ca689388d8fc..9b2ee323ef3c 100644 --- a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php +++ b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php @@ -168,6 +168,7 @@ class PageLayoutController $configuration->setShowHidden((bool)$this->moduleData->get('showHidden')); $configuration->setLanguageColumns($this->MOD_MENU['language']); $configuration->setSelectedLanguageId($this->currentSelectedLanguage); + $configuration->setAllowInconsistentLanguageHandling((bool)($tsConfig['mod.']['web_layout.']['allowInconsistentLanguageHandling'] ?? false)); if ((int)$this->moduleData->get('function') === 2) { $configuration->setLanguageMode(true); } diff --git a/typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php b/typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php index 6cec186aa050..1a106922b251 100644 --- a/typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php +++ b/typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php @@ -188,17 +188,21 @@ class ContentFetcher && $languageTranslationInfo['hasTranslations'] ) { $languageTranslationInfo['mode'] = 'mixed'; - $siteLanguage = $this->context->getSiteLanguage($language); - $message = GeneralUtility::makeInstance( - FlashMessage::class, - $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:staleTranslationWarning'), - sprintf($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:staleTranslationWarningTitle'), $siteLanguage->getTitle()), - ContextualFeedbackSeverity::WARNING - ); - $service = GeneralUtility::makeInstance(FlashMessageService::class); - $queue = $service->getMessageQueueByIdentifier(); - $queue->addMessage($message); + // We do not want to show the staleTranslationWarning if allowInconsistentLanguageHandling is enabled + $allowInconsistentLanguageHandling = (bool)(BackendUtility::getPagesTSconfig($this->context->getPageId())['mod.']['web_layout.']['allowInconsistentLanguageHandling'] ?? false); + if (!$this->context->getDrawingConfiguration()->getAllowInconsistentLanguageHandling()) { + $siteLanguage = $this->context->getSiteLanguage($language); + $message = GeneralUtility::makeInstance( + FlashMessage::class, + $this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:staleTranslationWarning'), + sprintf($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:staleTranslationWarningTitle'), $siteLanguage->getTitle()), + ContextualFeedbackSeverity::WARNING + ); + $service = GeneralUtility::makeInstance(FlashMessageService::class); + $queue = $service->getMessageQueueByIdentifier(); + $queue->addMessage($message); + } } $this->getRuntimeCache()->set('ContentFetcher_TranslationInfo_' . $language, $languageTranslationInfo); diff --git a/typo3/sysext/backend/Classes/View/Drawing/DrawingConfiguration.php b/typo3/sysext/backend/Classes/View/Drawing/DrawingConfiguration.php index cdf34b20710c..482c6a37aacc 100644 --- a/typo3/sysext/backend/Classes/View/Drawing/DrawingConfiguration.php +++ b/typo3/sysext/backend/Classes/View/Drawing/DrawingConfiguration.php @@ -39,6 +39,11 @@ class DrawingConfiguration */ protected $selectedLanguageId = 0; + /** + * Corresponds to web.layout.allowInconsistentLanguageHandling TSconfig property + */ + protected bool $allowInconsistentLanguageHandling = false; + /** * Determines whether rendering should happen with a visually aligned * connection between default language and translation. When rendered @@ -90,6 +95,16 @@ class DrawingConfiguration $this->selectedLanguageId = $selectedLanguageId; } + public function getAllowInconsistentLanguageHandling(): bool + { + return $this->allowInconsistentLanguageHandling; + } + + public function setAllowInconsistentLanguageHandling(bool $allowInconsistentLanguageHandling): void + { + $this->allowInconsistentLanguageHandling = $allowInconsistentLanguageHandling; + } + public function getDefaultLanguageBinding(): bool { return $this->defaultLanguageBinding; -- GitLab