diff --git a/typo3/sysext/core/Classes/Localization/LocalizationFactory.php b/typo3/sysext/core/Classes/Localization/LocalizationFactory.php index 91a1dd39e3e4ec1396f55154ec381b1102001e0a..c37c5876d1ca5323781016e3f51b967d648b89cf 100644 --- a/typo3/sysext/core/Classes/Localization/LocalizationFactory.php +++ b/typo3/sysext/core/Classes/Localization/LocalizationFactory.php @@ -79,24 +79,6 @@ class LocalizationFactory implements \TYPO3\CMS\Core\SingletonInterface */ public function getParsedData($fileReference, $languageKey, $charset = '', $errorMode = 0, $isLocalizationOverride = false) { - // @deprecated since CMS 7, will be removed with CMS 8 - // this is a fallback to convert references to old 'cms' locallang files to the new location - if (strpos($fileReference, 'EXT:cms') === 0) { - $mapping = [ - 'cms/web_info/loallang.xlf' => 'frontend/Resources/Private/Language/locallang_webinfo.xlf', - 'cms/locallang_ttc.xlf' => 'frontend/Resources/Private/Language/locallang_ttc.xlf', - 'cms/locallang_tca.xlf' => 'frontend/Resources/Private/Language/locallang_tca.xlf', - 'cms/layout/locallang_db_new_content_el.xlf' => 'backend/Resources/Private/Language/locallang_db_new_content_el.xlf', - 'cms/layout/locallang.xlf' => 'backend/Resources/Private/Language/locallang_layout.xlf', - 'cms/layout/locallang_mod.xlf' => 'backend/Resources/Private/Language/locallang_mod.xlf', - 'cms/locallang_csh_webinfo.xlf' => 'frontend/Resources/Private/Language/locallang_csh_webinfo.xlf', - 'cms/locallang_csh_weblayout.xlf' => 'frontend/Resources/Private/Language/locallang_csh_weblayout.xlf', - ]; - $filePath = substr($fileReference, 4); - GeneralUtility::deprecationLog('There is a reference to "' . $fileReference . '", which has been moved to "EXT:' . $mapping[$filePath] . '". This fallback will be removed with CMS 8.'); - $fileReference = 'EXT:' . $mapping[$filePath]; - } - $hash = md5($fileReference . $languageKey . $charset); $this->errorMode = $errorMode; diff --git a/typo3/sysext/core/Classes/Localization/Parser/LocallangArrayParser.php b/typo3/sysext/core/Classes/Localization/Parser/LocallangArrayParser.php deleted file mode 100644 index cffd7f77e5c6913ee9a59e099d0c9d769b205307..0000000000000000000000000000000000000000 --- a/typo3/sysext/core/Classes/Localization/Parser/LocallangArrayParser.php +++ /dev/null @@ -1,236 +0,0 @@ -<?php -namespace TYPO3\CMS\Core\Localization\Parser; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use TYPO3\CMS\Core\Charset\CharsetConverter; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\PathUtility; - -/** - * Parser for PHP locallang array. - * - * @deprecated since TYPO3 CMS 7, this file will be removed in TYPO3 CMS 8. Please use XLF files for - * translation handling. Also note that the extension "extdeveval" has a converter from PHP and XML to XLF. - */ -class LocallangArrayParser implements LocalizationParserInterface -{ - /** - * @var string - */ - protected $cacheFileName; - - /** - * @var \TYPO3\CMS\Core\Charset\CharsetConverter - */ - protected $csConvObj; - - /** - * @var string - */ - protected $hashSource; - - /** - * @var string - */ - protected $sourceCharset; - - /** - * @var string - */ - protected $targetCharset; - - /** - * Initializes the parser. - * - * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8. Use xlf format for parsing translations - */ - public function __construct() - { - GeneralUtility::logDeprecatedFunction(); - $this->createCsConvObject(); - } - - /** - * Returns parsed representation of PHP locallang file. - * - * @param string $sourcePath Source file path - * @param string $languageKey Language key - * @param string $charset Charset - * @return array - * @throws \RuntimeException - */ - public function getParsedData($sourcePath, $languageKey, $charset = '') - { - $this->validateParameters($sourcePath, $languageKey); - $this->setCharsets($languageKey, $charset); - $this->generateCacheFileName($sourcePath, $languageKey); - if (!file_exists($this->cacheFileName)) { - $LOCAL_LANG = $this->generateCacheFile($sourcePath, $languageKey); - } else { - $LOCAL_LANG = $this->getContentFromCacheFile(); - } - $xliff = $this->convertToXLIFF($LOCAL_LANG); - return $xliff; - } - - /** - * Converts the LOCAL_LANG array to XLIFF structure. - * - * @param array $LOCAL_LANG - * @return array - */ - protected function convertToXLIFF(array $LOCAL_LANG) - { - foreach ($LOCAL_LANG as &$keysLabels) { - foreach ($keysLabels as &$label) { - $label = array( - 0 => array( - 'target' => $label - ) - ); - } - unset($label); - } - return $LOCAL_LANG; - } - - /** - * Creates a character conversion object. - * - * @return void - */ - protected function createCsConvObject() - { - if (is_object($GLOBALS['LANG'])) { - $this->csConvObj = $GLOBALS['LANG']->csConvObj; - } elseif (is_object($GLOBALS['TSFE'])) { - $this->csConvObj = $GLOBALS['TSFE']->csConvObj; - } else { - $this->csConvObj = GeneralUtility::makeInstance(CharsetConverter::class); - } - } - - /** - * Generates the cache file. - * - * @param string $sourcePath - * @param string $languageKey - * @return array - * @throws \RuntimeException - */ - protected function generateCacheFile($sourcePath, $languageKey) - { - $LOCAL_LANG = array(); - // Get PHP data - include $sourcePath; - if (!is_array($LOCAL_LANG)) { - $fileName = PathUtility::stripPathSitePrefix($sourcePath); - throw new \RuntimeException('TYPO3 Fatal Error: "' . $fileName . '" is no TYPO3 language file!', 1308898491); - } - // Converting the default language (English) - // This needs to be done for a few accented loan words and extension names - if (is_array($LOCAL_LANG['default']) && $this->targetCharset !== 'utf-8') { - foreach ($LOCAL_LANG['default'] as &$labelValue) { - $labelValue = $this->csConvObj->conv($labelValue, 'utf-8', $this->targetCharset); - } - unset($labelValue); - } - if ($languageKey !== 'default' && is_array($LOCAL_LANG[$languageKey]) && $this->sourceCharset !== $this->targetCharset) { - foreach ($LOCAL_LANG[$languageKey] as &$labelValue) { - $labelValue = $this->csConvObj->conv($labelValue, $this->sourceCharset, $this->targetCharset); - } - unset($labelValue); - } - // Cache the content now: - if (isset($LOCAL_LANG[$languageKey])) { - $serContent = array('origFile' => $this->hashSource, 'LOCAL_LANG' => array('default' => $LOCAL_LANG['default'], $languageKey => $LOCAL_LANG[$languageKey])); - } else { - $serContent = array('origFile' => $this->hashSource, 'LOCAL_LANG' => array('default' => $LOCAL_LANG['default'])); - } - $res = GeneralUtility::writeFileToTypo3tempDir($this->cacheFileName, serialize($serContent)); - if ($res) { - throw new \RuntimeException('TYPO3 Fatal Error: "' . $res, 1308898501); - } - return $LOCAL_LANG; - } - - /** - * Generates the name of the cached file. - * - * @param string $sourcePath - * @param string $languageKey - * @return void - */ - protected function generateCacheFileName($sourcePath, $languageKey) - { - $this->hashSource = PathUtility::stripPathSitePrefix($sourcePath) . '|' . date('d-m-Y H:i:s', filemtime($sourcePath)) . '|version=2.3'; - $this->cacheFileName = PATH_site . 'typo3temp/llxml/' . substr(basename($sourcePath), 10, 15) . '_' . GeneralUtility::shortMD5($this->hashSource) . '.' . $languageKey . '.' . $this->targetCharset . '.cache'; - } - - /** - * Obtains the content from the cache file. - * - * @return array - */ - protected function getContentFromCacheFile() - { - $serContent = (array)unserialize(file_get_contents($this->cacheFileName)); - $LOCAL_LANG = $serContent['LOCAL_LANG']; - return (array)$LOCAL_LANG; - } - - /** - * Checks if the file is within the web root. - * - * @param string $fileName - * @return bool - */ - protected function isWithinWebRoot($fileName) - { - return (bool)GeneralUtility::getFileAbsFileName($fileName); - } - - /** - * Sets character sets for the language key. - * - * @param string $languageKey - * @param string $charset - * @return void - */ - protected function setCharsets($languageKey, $charset) - { - $this->sourceCharset = $this->csConvObj->parse_charset($this->csConvObj->charSetArray[$languageKey] ?: 'utf-8'); - if ($charset) { - $this->targetCharset = $this->csConvObj->parse_charset($charset); - } else { - $this->targetCharset = 'utf-8'; - } - } - - /** - * Validates parameters for the function. - * - * @param string $sourcePath - * @param string $languageKey - * @return void - * @throws \RuntimeException - */ - protected function validateParameters($sourcePath, $languageKey) - { - if (!$this->isWithinWebRoot($sourcePath) || !@is_file($sourcePath) || !$languageKey) { - throw new \RuntimeException(sprintf('Invalid source path (%s) or languageKey (%s)', $sourcePath, $languageKey), 1309245002); - } - } -} diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-72412-RemovedDeprecatedCodeFromLanguageProcessingFunctions.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-72412-RemovedDeprecatedCodeFromLanguageProcessingFunctions.rst new file mode 100755 index 0000000000000000000000000000000000000000..381a6d8c0c13b3d05bb7f9b7cce986b0cfd0c982 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-72412-RemovedDeprecatedCodeFromLanguageProcessingFunctions.rst @@ -0,0 +1,37 @@ +============================================================================= +Breaking: #72412 - Removed deprecated code from language processing functions +============================================================================= + +Description +=========== + +The following deprecated code has been removed: + +* ``LocalizationFactory::getParsedData`` no support for moved language files +* class ``LocallangArrayParser`` has been removed completely + +The following deprecated methods have been removed: + +* ``LanguageService::localizedFileRef`` + + +Impact +====== + +Using old locations of language file will result in no text being displayed. +Using the removed class will result in a fatal error. +Using the methods above directly in any third party extension will result in a fatal error. + + +Affected Installations +====================== + +Instances which use old locations of language files, instances which use the removed class LocallangArrayParser, instances which use calls to the methods above. + + +Migration +========= + +``LocalizationFactory::getParsedData`` only supports the new location of language files +``LocallangArrayParser`` use XLIFF language files now +``\TYPO3\CMS\Lang\LanguageService::localizedFileRef`` no replacement; not needed when XLIFF files are used diff --git a/typo3/sysext/lang/Classes/LanguageService.php b/typo3/sysext/lang/Classes/LanguageService.php old mode 100644 new mode 100755 index 694b662e84a3721bc9ccd4fc7f57a766cc41de75..dbbc7ccef0e42ef0ccdf91e093f8b067c824fbb1 --- a/typo3/sysext/lang/Classes/LanguageService.php +++ b/typo3/sysext/lang/Classes/LanguageService.php @@ -172,7 +172,7 @@ class LanguageService * * @param string $str Input string * @return string Output string - * @deprecated since TYPO3 v8, will be removed in v9 + * @deprecated since TYPO3 CMS 8, will be removed in TYPO3 CMS 9 */ public function makeEntities($str) { @@ -264,12 +264,6 @@ class LanguageService // Getting data if not cached if (!isset($this->LL_files_cache[$parts[0]])) { $this->LL_files_cache[$parts[0]] = $this->readLLfile($parts[0]); - // If the current language is found in another file, load that as well: - $lFileRef = $this->localizedFileRef($parts[0]); - if ($lFileRef && $this->LL_files_cache[$parts[0]][$this->lang] === 'EXT') { - $tempLL = $this->readLLfile($lFileRef); - $this->LL_files_cache[$parts[0]][$this->lang] = $tempLL[$this->lang]; - } } $output = $this->getLLL($parts[1], $this->LL_files_cache[$parts[0]]); } else { @@ -370,12 +364,6 @@ class LanguageService ArrayUtility::mergeRecursiveWithOverrule($globalLanguage, $localLanguage); } else { $globalLanguage = $localLanguage; - } - // Localized addition? - $lFileRef = $this->localizedFileRef($fileRef); - if ($lFileRef && (string)$globalLanguage[$this->lang] === 'EXT') { - $localLanguage = $this->readLLfile($lFileRef); - ArrayUtility::mergeRecursiveWithOverrule($globalLanguage, $localLanguage); } // Merge local onto default if ($mergeLocalOntoDefault && $this->lang !== 'default' && is_array($globalLanguage[$this->lang]) && is_array($globalLanguage['default'])) { @@ -430,23 +418,6 @@ class LanguageService return $localLanguage; } - /** - * Returns localized fileRef (.[langkey].php) - * - * @param string $fileRef Filename/path of a 'locallang.php' file - * @return string Input filename with a '.[lang-key].php' ending added if $this->lang is not 'default' - * @deprecated since TYPO3 CMS 7, this method will be removed in CMS 8. Please use XLF files for translation handling. - */ - protected function localizedFileRef($fileRef) - { - if ($this->lang !== 'default' && substr($fileRef, -4) === '.php') { - GeneralUtility::logDeprecatedFunction(); - return substr($fileRef, 0, -4) . '.' . $this->lang . '.php'; - } else { - return null; - } - } - /** * Overrides a label. *