From 45c3416c1b2d9f05858fc5ca986d7fa03fcaebef Mon Sep 17 00:00:00 2001 From: Thorsten Schramm Date: Fri, 10 Mar 2023 11:31:37 +0100 Subject: [PATCH] bugfix for PHP 8.1 compatibility --- Classes/Adminpanel/Modules/TranslateLabel/TranslateLabel.php | 2 +- .../Adminpanel/Modules/TranslateLabel/TranslateLabelInfo.php | 2 +- Classes/Renderer/FrontendRenderer.php | 3 ++- Classes/Utility/TranslationLabelUtility.php | 2 +- ext_emconf.php | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Classes/Adminpanel/Modules/TranslateLabel/TranslateLabel.php b/Classes/Adminpanel/Modules/TranslateLabel/TranslateLabel.php index 5d18e25..3a48e04 100644 --- a/Classes/Adminpanel/Modules/TranslateLabel/TranslateLabel.php +++ b/Classes/Adminpanel/Modules/TranslateLabel/TranslateLabel.php @@ -66,7 +66,7 @@ public function getDataToStore(ServerRequestInterface $request): ModuleData $iconFactory = GeneralUtility::makeInstance(IconFactory::class); return new ModuleData( [ - 'labels' => $GLOBALS['TRANSLATELABELS'], + 'labels' => $GLOBALS['TRANSLATELABELS'] ?? [], 'showTranslateLabels' => $this->configurationService->getConfigurationOption('translatelabels', 'showTranslationLabels'), 'saveUrl' => $this->generateBackendUrl('ajax_translatelabels_translate'), 'sysLanguageUid' => $this->context->getPropertyFromAspect('language', 'id'), diff --git a/Classes/Adminpanel/Modules/TranslateLabel/TranslateLabelInfo.php b/Classes/Adminpanel/Modules/TranslateLabel/TranslateLabelInfo.php index 5163555..76cf901 100644 --- a/Classes/Adminpanel/Modules/TranslateLabel/TranslateLabelInfo.php +++ b/Classes/Adminpanel/Modules/TranslateLabel/TranslateLabelInfo.php @@ -87,7 +87,7 @@ public function getDataToStore(ServerRequestInterface $request): ModuleData $iconFactory = GeneralUtility::makeInstance(IconFactory::class); return new ModuleData( [ - 'labels' => $GLOBALS['TRANSLATELABELS'], + 'labels' => $GLOBALS['TRANSLATELABELS'] ?? [], 'showTranslateLabels' => $this->configurationService->getConfigurationOption('translatelabels', 'showTranslationLabels'), 'editIcon' => $iconFactory->getIcon('actions-open', Icon::SIZE_SMALL)->render() ] diff --git a/Classes/Renderer/FrontendRenderer.php b/Classes/Renderer/FrontendRenderer.php index 541372d..3027ffb 100644 --- a/Classes/Renderer/FrontendRenderer.php +++ b/Classes/Renderer/FrontendRenderer.php @@ -222,6 +222,7 @@ protected function getOverrides(int $pid, string $labelKey, string $extensionNam } } $pluginName = (strpos($extensionName, 'tx_') === 0) ? $extensionName : 'tx_' . strtolower($extensionName); + $typoScriptOverride = []; if (isset($GLOBALS['TSFE']->tmpl->setup['plugin.'][$pluginName . '.']['_LOCAL_LANG.'][$languageKey . '.']) && is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'][$pluginName . '.']['_LOCAL_LANG.'][$languageKey . '.'])) { $typoScriptOverride = ArrayUtility::flatten( @@ -229,7 +230,7 @@ protected function getOverrides(int $pid, string $labelKey, string $extensionNam '.' ); } - if ($typoScriptOverride['.' . $labelName]) { + if (!empty($typoScriptOverride['.' . $labelName])) { $overrides[] = ['TypoScript' , 'plugin.' . $pluginName . '._LOCAL_LANG.' . $languageKey . '.' . $labelName]; } if (TranslationLabelUtility::getLabelFromDatabase($labelKey, $pid) !== null) { diff --git a/Classes/Utility/TranslationLabelUtility.php b/Classes/Utility/TranslationLabelUtility.php index 7c12828..379e165 100644 --- a/Classes/Utility/TranslationLabelUtility.php +++ b/Classes/Utility/TranslationLabelUtility.php @@ -185,7 +185,7 @@ public static function getDefaultLanguageFile($extensionName) public static function getExtendLabelKeyWithLanguageFilePath($labelKey, $extensionName) { $reversedParts = explode(':', strrev($labelKey), 2); - $languageFile = strrev($reversedParts[1]); + $languageFile = strrev($reversedParts[1] ?? ''); $extendedLabelKey = $labelKey; if ($languageFile === '') { // $extendedLabelKey = 'LLL:EXT:' . self::getDefaultLanguageFile($extensionName) . ':' . $labelKey; diff --git a/ext_emconf.php b/ext_emconf.php index 84538c0..9d562af 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -7,7 +7,7 @@ 'author' => 'Alexander Bohndorf', 'author_email' => 'bohndorf@sitegeist.de', 'state' => 'beta', - 'version' => '2.2.1', + 'version' => '2.3.0', 'constraints' => [ 'depends' => [ 'typo3' => '10.0.0-11.5.99',