From b1b9901298700fd90e4a6900dc568837b6b36386 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Tue, 14 Jul 2015 15:20:12 +0200
Subject: [PATCH] [TASK] Deprecate GeneralUtility:readLLfile

readLLfile() was just a wrapper around LocalizationFactory.
This is resolved now by adapting all calls and moving a left
over code snippet to the factory method.

Resolves: #68122
Releases: master
Change-Id: Ib416e380f25b06a055b7f25103e19925b29d7fde
Reviewed-on: http://review.typo3.org/41197
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
---
 .../Localization/LocalizationFactory.php      | 20 +++++-
 .../sysext/core/Classes/Page/PageRenderer.php |  7 +-
 .../core/Classes/Utility/GeneralUtility.php   | 20 +-----
 ...ecation-68122-GeneralUtilityReadLLfile.rst | 34 ++++++++++
 .../Localization/LocalizationFactoryTest.php  | 65 +++++++++++++++++++
 .../Parser/LocallangXmlParserTest.php         | 19 +++++-
 .../Localization/Parser/XliffParserTest.php   | 14 +++-
 .../Tests/Unit/Utility/GeneralUtilityTest.php | 38 -----------
 .../Classes/Utility/LocalizationUtility.php   |  9 ++-
 .../TypoScriptFrontendController.php          |  6 +-
 .../Classes/Plugin/AbstractPlugin.php         |  8 ++-
 typo3/sysext/lang/Classes/LanguageService.php |  9 +--
 .../Classes/Form/Element/RichTextElement.php  |  5 +-
 13 files changed, 181 insertions(+), 73 deletions(-)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-68122-GeneralUtilityReadLLfile.rst
 create mode 100644 typo3/sysext/core/Tests/Unit/Localization/LocalizationFactoryTest.php

diff --git a/typo3/sysext/core/Classes/Localization/LocalizationFactory.php b/typo3/sysext/core/Classes/Localization/LocalizationFactory.php
index 8f1a53948d60..c8ed49548583 100644
--- a/typo3/sysext/core/Classes/Localization/LocalizationFactory.php
+++ b/typo3/sysext/core/Classes/Localization/LocalizationFactory.php
@@ -77,7 +77,25 @@ class LocalizationFactory implements \TYPO3\CMS\Core\SingletonInterface {
 	 * @param bool $isLocalizationOverride TRUE if $fileReference is a localization override
 	 * @return array|boolean
 	 */
-	public function getParsedData($fileReference, $languageKey, $charset, $errorMode, $isLocalizationOverride = FALSE) {
+	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];
+		}
+
 		try {
 			$hash = md5($fileReference . $languageKey . $charset);
 			$this->errorMode = $errorMode;
diff --git a/typo3/sysext/core/Classes/Page/PageRenderer.php b/typo3/sysext/core/Classes/Page/PageRenderer.php
index 86698eca2a56..5d22a1adb4ee 100644
--- a/typo3/sysext/core/Classes/Page/PageRenderer.php
+++ b/typo3/sysext/core/Classes/Page/PageRenderer.php
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Page;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -2507,6 +2508,9 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface {
 	 * @return array Returns the $LOCAL_LANG array found in the file. If no array found, returns empty array.
 	 */
 	protected function readLLfile($fileRef, $errorMode = 0) {
+		/** @var $languageFactory LocalizationFactory */
+		$languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
+
 		if ($this->lang !== 'default') {
 			$languages = array_reverse($this->languageDependencies);
 			// At least we need to have English
@@ -2519,7 +2523,8 @@ class PageRenderer implements \TYPO3\CMS\Core\SingletonInterface {
 
 		$localLanguage = array();
 		foreach ($languages as $language) {
-			$tempLL = GeneralUtility::readLLfile($fileRef, $language, $this->charSet, $errorMode);
+			$tempLL = $languageFactory->getParsedData($fileRef, $language, $this->charSet, $errorMode);
+
 			$localLanguage['default'] = $tempLL['default'];
 			if (!isset($localLanguage[$this->lang])) {
 				$localLanguage[$this->lang] = $localLanguage['default'];
diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
index c6ab2613752b..64d357cd5ad4 100755
--- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php
+++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
@@ -3983,26 +3983,10 @@ Connection: close
 	 * @param string $charset Character set (option); if not set, determined by the language key
 	 * @param int $errorMode Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception
 	 * @return array Value of $LOCAL_LANG found in the included file. If that array is found it will returned.
+	 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
 	 */
 	static public function readLLfile($fileRef, $langKey, $charset = '', $errorMode = 0) {
-		// @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($fileRef, '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($fileRef, 4);
-			self::deprecationLog('There is a reference to "' . $fileRef . '", which has been moved to "EXT:' . $mapping[$filePath] . '". This fallback will be removed with CMS 8.');
-			$fileRef = 'EXT:' . $mapping[$filePath];
-		}
-
+		self::logDeprecatedFunction();
 		/** @var $languageFactory \TYPO3\CMS\Core\Localization\LocalizationFactory */
 		$languageFactory = self::makeInstance(\TYPO3\CMS\Core\Localization\LocalizationFactory::class);
 		return $languageFactory->getParsedData($fileRef, $langKey, $charset, $errorMode);
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-68122-GeneralUtilityReadLLfile.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-68122-GeneralUtilityReadLLfile.rst
new file mode 100644
index 000000000000..6eb5178b0c57
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-68122-GeneralUtilityReadLLfile.rst
@@ -0,0 +1,34 @@
+==========================================================
+Deprecation: #68122 - Deprecate GeneralUtility::readLLfile
+==========================================================
+
+Description
+===========
+
+Method ``GeneralUtility::realLLfile()`` was just a wrapper around LocalizationFactory
+and has been deprecated.
+
+
+Impact
+======
+
+Extensions using ``realLLfile()`` to parse localization files should switch to
+an instance of ``LocalizationFactory``.
+
+
+Affected Installations
+======================
+
+Extensions using ``GeneralUtility::readLLfile()``
+
+
+Migration
+=========
+
+A typical call now should look like:
+
+.. code-block:: php
+
+		/** @var $languageFactory \TYPO3\CMS\Core\Localization\LocalizationFactory */
+		$languageFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LocalizationFactory::class);
+		$languageFactory->getParsedData($fileToParse, $language, $renderCharset, $errorMode);
diff --git a/typo3/sysext/core/Tests/Unit/Localization/LocalizationFactoryTest.php b/typo3/sysext/core/Tests/Unit/Localization/LocalizationFactoryTest.php
new file mode 100644
index 000000000000..b6885423b02d
--- /dev/null
+++ b/typo3/sysext/core/Tests/Unit/Localization/LocalizationFactoryTest.php
@@ -0,0 +1,65 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Localization;
+
+/*
+ * 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\Localization\LocalizationFactory;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
+/**
+ * Test case
+ *
+ * @author Xavier Perseguers <xavier@typo3.org>
+ */
+class LocalizationFactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
+
+	/**
+	 * @test
+	 */
+	public function getParsedDataHandlesLocallangXMLOverride() {
+		/** @var $subject LocalizationFactory */
+		$subject = new LocalizationFactory;
+
+		$unique = 'locallangXMLOverrideTest' . substr($this->getUniqueId(), 0, 10);
+		$xml = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+			<T3locallang>
+				<data type="array">
+					<languageKey index="default" type="array">
+						<label index="buttons.logout">EXIT</label>
+					</languageKey>
+				</data>
+			</T3locallang>';
+		$file = PATH_site . 'typo3temp/' . $unique . '.xml';
+		GeneralUtility::writeFileToTypo3tempDir($file, $xml);
+		// Make sure there is no cached version of the label
+		GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('l10n')->flush();
+		// Get default value
+		$defaultLL = $subject->getParsedData('EXT:lang/locallang_core.xlf', 'default');
+		// Clear language cache again
+		GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('l10n')->flush();
+		// Set override file
+		$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:lang/locallang_core.xlf'][$unique] = $file;
+		/** @var $store \TYPO3\CMS\Core\Localization\LanguageStore */
+		$store = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageStore::class);
+		$store->flushData('EXT:lang/locallang_core.xlf');
+		// Get override value
+		$overrideLL = $subject->getParsedData('EXT:lang/locallang_core.xlf', 'default');
+		// Clean up again
+		unlink($file);
+		$this->assertNotEquals($overrideLL['default']['buttons.logout'][0]['target'], '');
+		$this->assertNotEquals($defaultLL['default']['buttons.logout'][0]['target'], $overrideLL['default']['buttons.logout'][0]['target']);
+		$this->assertEquals($overrideLL['default']['buttons.logout'][0]['target'], 'EXIT');
+	}
+
+}
diff --git a/typo3/sysext/core/Tests/Unit/Localization/Parser/LocallangXmlParserTest.php b/typo3/sysext/core/Tests/Unit/Localization/Parser/LocallangXmlParserTest.php
index 62bb2046fbe2..145f22ddca9d 100644
--- a/typo3/sysext/core/Tests/Unit/Localization/Parser/LocallangXmlParserTest.php
+++ b/typo3/sysext/core/Tests/Unit/Localization/Parser/LocallangXmlParserTest.php
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Localization\Parser;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Localization\LocalizationFactory;
 
 /**
  * Testcase for class \TYPO3\CMS\Core\Localization\Parser\LocallangXmlParser.
@@ -118,8 +119,14 @@ class LocallangXmlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 	 * @test
 	 */
 	public function canOverrideLlxml() {
+		/** @var $factory LocalizationFactory */
+		$factory = new LocalizationFactory;
+
 		$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'][self::getFixtureFilePath('locallang.xml')][] = self::getFixtureFilePath('locallang_override.xml');
-		$LOCAL_LANG = array_merge(\TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile(self::getFixtureFilePath('locallang.xml'), 'default'), \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile(self::getFixtureFilePath('locallang.xml'), 'md5'));
+		$LOCAL_LANG = array_merge(
+			$factory->getParsedData(self::getFixtureFilePath('locallang.xml'), 'default'),
+			$factory->getParsedData(self::getFixtureFilePath('locallang.xml'), 'md5')
+		);
 		$this->assertArrayHasKey('default', $LOCAL_LANG, 'default key not found in $LOCAL_LANG');
 		$this->assertArrayHasKey('md5', $LOCAL_LANG, 'md5 key not found in $LOCAL_LANG');
 		$expectedLabels = array(
@@ -142,7 +149,10 @@ class LocallangXmlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 	}
 
 	public function numericKeysDataProvider() {
-		$LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile(self::getFixtureFilePath('locallangNumericKeys.xml'), 'default');
+		/** @var $factory LocalizationFactory */
+		$factory = new LocalizationFactory;
+
+		$LOCAL_LANG = $factory->getParsedData(self::getFixtureFilePath('locallangNumericKeys.xml'), 'default');
 		$translations = array();
 
 		foreach ($LOCAL_LANG['default'] as $key => $labelData) {
@@ -157,7 +167,10 @@ class LocallangXmlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 	 * @dataProvider numericKeysDataProvider
 	 */
 	public function canTranslateNumericKeys($key, $expectedResult) {
-		$LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile(self::getFixtureFilePath('locallangNumericKeys.xml'), 'fr');
+		/** @var $factory LocalizationFactory */
+		$factory = new LocalizationFactory;
+
+		$LOCAL_LANG = $factory->getParsedData(self::getFixtureFilePath('locallangNumericKeys.xml'), 'fr');
 
 		$this->assertEquals($expectedResult, $LOCAL_LANG['fr'][$key][0]['target']);
 	}
diff --git a/typo3/sysext/core/Tests/Unit/Localization/Parser/XliffParserTest.php b/typo3/sysext/core/Tests/Unit/Localization/Parser/XliffParserTest.php
index 62b0da871934..af3e3962a18f 100644
--- a/typo3/sysext/core/Tests/Unit/Localization/Parser/XliffParserTest.php
+++ b/typo3/sysext/core/Tests/Unit/Localization/Parser/XliffParserTest.php
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Localization\Parser;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Localization\LocalizationFactory;
 
 /**
  * Testcase for class \TYPO3\CMS\Core\Localization\Parser\XliffParser.
@@ -110,9 +111,15 @@ class XliffParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 	 * @test
 	 */
 	public function canOverrideXliff() {
+		/** @var $factory LocalizationFactory */
+		$factory = new LocalizationFactory;
+
 		$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'][$this->xliffFileNames['locallang']][] = $this->xliffFileNames['locallang_override'];
 		$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['fr'][$this->xliffFileNames['locallang']][] = $this->xliffFileNames['locallang_override_fr'];
-		$LOCAL_LANG = array_merge(\TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile($this->xliffFileNames['locallang'], 'default'), \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile($this->xliffFileNames['locallang'], 'fr'));
+		$LOCAL_LANG = array_merge(
+			$factory->getParsedData($this->xliffFileNames['locallang'], 'default'),
+			$factory->getParsedData($this->xliffFileNames['locallang'], 'fr')
+		);
 		$this->assertArrayHasKey('default', $LOCAL_LANG, 'default key not found in $LOCAL_LANG');
 		$this->assertArrayHasKey('fr', $LOCAL_LANG, 'fr key not found in $LOCAL_LANG');
 		$expectedLabels = array(
@@ -141,8 +148,11 @@ class XliffParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 	 * @test
 	 */
 	public function canOverrideXliffWithFrenchOnly() {
+		/** @var $factory LocalizationFactory */
+		$factory = new LocalizationFactory;
+
 		$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['fr'][$this->xliffFileNames['locallang']][] = $this->xliffFileNames['locallang_override_fr'];
-		$LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile($this->xliffFileNames['locallang'], 'fr');
+		$LOCAL_LANG = $factory->getParsedData($this->xliffFileNames['locallang'], 'fr');
 		$this->assertArrayHasKey('fr', $LOCAL_LANG, 'fr key not found in $LOCAL_LANG');
 		$expectedLabels = array(
 			'label1' => 'Ceci est mon 1er libellé',
diff --git a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
index 3198066ab5a6..5819780209b4 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
@@ -2369,44 +2369,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 		$this->assertSame('\'' . $expected . '\'', GeneralUtility::quoteJSvalue($input));
 	}
 
-	//////////////////////////////////
-	// Tests concerning readLLfile
-	//////////////////////////////////
-	/**
-	 * @test
-	 */
-	public function readLLfileHandlesLocallangXMLOverride() {
-		$unique = 'locallangXMLOverrideTest' . substr($this->getUniqueId(), 0, 10);
-		$xml = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-			<T3locallang>
-				<data type="array">
-					<languageKey index="default" type="array">
-						<label index="buttons.logout">EXIT</label>
-					</languageKey>
-				</data>
-			</T3locallang>';
-		$file = PATH_site . 'typo3temp/' . $unique . '.xml';
-		GeneralUtility::writeFileToTypo3tempDir($file, $xml);
-		// Make sure there is no cached version of the label
-		GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('l10n')->flush();
-		// Get default value
-		$defaultLL = GeneralUtility::readLLfile('EXT:lang/locallang_core.xlf', 'default');
-		// Clear language cache again
-		GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('l10n')->flush();
-		// Set override file
-		$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:lang/locallang_core.xlf'][$unique] = $file;
-		/** @var $store \TYPO3\CMS\Core\Localization\LanguageStore */
-		$store = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageStore::class);
-		$store->flushData('EXT:lang/locallang_core.xlf');
-		// Get override value
-		$overrideLL = GeneralUtility::readLLfile('EXT:lang/locallang_core.xlf', 'default');
-		// Clean up again
-		unlink($file);
-		$this->assertNotEquals($overrideLL['default']['buttons.logout'][0]['target'], '');
-		$this->assertNotEquals($defaultLL['default']['buttons.logout'][0]['target'], $overrideLL['default']['buttons.logout'][0]['target']);
-		$this->assertEquals($overrideLL['default']['buttons.logout'][0]['target'], 'EXIT');
-	}
-
 	///////////////////////////////
 	// Tests concerning _GETset()
 	///////////////////////////////
diff --git a/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php b/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php
index faf77e549534..e5b77b3e47d0 100644
--- a/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php
+++ b/typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Extbase\Utility;
  */
 
 use TYPO3\CMS\Core\Localization\Locales;
+use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
@@ -163,9 +164,13 @@ class LocalizationUtility {
 		$locallangPathAndFilename = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName) . '/' . self::$locallangPath . 'locallang.xlf';
 		self::setLanguageKeys();
 		$renderCharset = TYPO3_MODE === 'FE' ? self::getTypoScriptFrontendController()->renderCharset : self::getLanguageService()->charSet;
-		self::$LOCAL_LANG[$extensionName] = GeneralUtility::readLLfile($locallangPathAndFilename, self::$languageKey, $renderCharset);
+
+		/** @var $languageFactory LocalizationFactory */
+		$languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
+
+		self::$LOCAL_LANG[$extensionName] = $languageFactory->getParsedData($locallangPathAndFilename, self::$languageKey, $renderCharset);
 		foreach (self::$alternativeLanguageKeys as $language) {
-			$tempLL = GeneralUtility::readLLfile($locallangPathAndFilename, $language, $renderCharset);
+			$tempLL = $languageFactory->getParsedData($locallangPathAndFilename, $language, $renderCharset);
 			if (self::$languageKey !== 'default' && isset($tempLL[$language])) {
 				self::$LOCAL_LANG[$extensionName][$language] = $tempLL[$language];
 			}
diff --git a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
index 3b6210916bc7..f7ca37bbc528 100644
--- a/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
+++ b/typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
@@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Charset\CharsetConverter;
 use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
 use TYPO3\CMS\Core\Error\Http\ServiceUnavailableException;
 use TYPO3\CMS\Core\Localization\Locales;
+use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Locking\Exception\LockAcquireWouldBlockException;
 use TYPO3\CMS\Core\Locking\Locker;
 use TYPO3\CMS\Core\Messaging\ErrorpageMessage;
@@ -4406,6 +4407,9 @@ class TypoScriptFrontendController {
 	 * @return array Returns the $LOCAL_LANG array found in the file. If no array found, returns empty array.
 	 */
 	public function readLLfile($fileRef) {
+		/** @var $languageFactory LocalizationFactory */
+		$languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
+
 		if ($this->lang !== 'default') {
 			$languages = array_reverse($this->languageDependencies);
 			// At least we need to have English
@@ -4418,7 +4422,7 @@ class TypoScriptFrontendController {
 
 		$localLanguage = array();
 		foreach ($languages as $language) {
-			$tempLL = GeneralUtility::readLLfile($fileRef, $language, $this->renderCharset);
+			$tempLL = $languageFactory->getParsedData($fileRef, $language, $this->renderCharset);
 			$localLanguage['default'] = $tempLL['default'];
 			if (!isset($localLanguage[$this->lang])) {
 				$localLanguage[$this->lang] = $localLanguage['default'];
diff --git a/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php b/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php
index 93078d7a4c0e..8be85eab2933 100644
--- a/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php
+++ b/typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Frontend\Plugin;
  */
 
 use TYPO3\CMS\Core\Localization\Locales;
+use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -982,12 +983,15 @@ class AbstractPlugin {
 	 */
 	public function pi_loadLL() {
 		if (!$this->LOCAL_LANG_loaded && $this->scriptRelPath) {
+			/** @var $languageFactory LocalizationFactory */
+			$languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
+
 			$basePath = 'EXT:' . $this->extKey . '/' . dirname($this->scriptRelPath) . '/locallang.xlf';
 			// Read the strings in the required charset (since TYPO3 4.2)
-			$this->LOCAL_LANG = GeneralUtility::readLLfile($basePath, $this->LLkey, $this->frontendController->renderCharset);
+			$this->LOCAL_LANG = $languageFactory->getParsedData($basePath, $this->LLkey, $this->frontendController->renderCharset);
 			$alternativeLanguageKeys = GeneralUtility::trimExplode(',', $this->altLLkey, TRUE);
 			foreach ($alternativeLanguageKeys as $languageKey) {
-				$tempLL = GeneralUtility::readLLfile($basePath, $languageKey);
+				$tempLL = $languageFactory->getParsedData($basePath, $languageKey);
 				if ($this->LLkey !== 'default' && isset($tempLL[$languageKey])) {
 					$this->LOCAL_LANG[$languageKey] = $tempLL[$languageKey];
 				}
diff --git a/typo3/sysext/lang/Classes/LanguageService.php b/typo3/sysext/lang/Classes/LanguageService.php
index 7a22abd99f7e..2941e3088380 100644
--- a/typo3/sysext/lang/Classes/LanguageService.php
+++ b/typo3/sysext/lang/Classes/LanguageService.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Lang;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -97,7 +98,7 @@ class LanguageService {
 	/**
 	 * instance of the parser factory
 	 *
-	 * @var \TYPO3\CMS\Core\Localization\LocalizationFactory
+	 * @var LocalizationFactory
 	 */
 	public $parserFactory;
 
@@ -124,7 +125,7 @@ class LanguageService {
 		$this->csConvObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Charset\CharsetConverter::class);
 		$this->charSetArray = $this->csConvObj->charSetArray;
 		// Initialize the parser factory object
-		$this->parserFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LocalizationFactory::class);
+		$this->parserFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
 		// Find the requested language in this list based
 		// on the $lang key being inputted to this function.
 		/** @var $locales \TYPO3\CMS\Core\Localization\Locales */
@@ -146,7 +147,7 @@ class LanguageService {
 	/**
 	 * Gets the parser factory.
 	 *
-	 * @return \TYPO3\CMS\Core\Localization\LocalizationFactory
+	 * @return LocalizationFactory
 	 */
 	public function getParserFactory() {
 		return $this->parserFactory;
@@ -413,7 +414,7 @@ class LanguageService {
 		}
 		$localLanguage = array();
 		foreach ($languages as $language) {
-			$tempLL = GeneralUtility::readLLfile($fileRef, $language, $this->charSet);
+			$tempLL = $this->parserFactory->getParsedData($fileRef, $language, $this->charSet);
 			$localLanguage['default'] = $tempLL['default'];
 			if (!isset($localLanguage[$this->lang])) {
 				$localLanguage[$this->lang] = $localLanguage['default'];
diff --git a/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php b/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php
index 46ed9a9a5902..5b5425791e65 100644
--- a/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php
+++ b/typo3/sysext/rtehtmlarea/Classes/Form/Element/RichTextElement.php
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Rtehtmlarea\Form\Element;
 
 use TYPO3\CMS\Backend\Form\Element\AbstractFormElement;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\FrontendEditing\FrontendEditingController;
@@ -1042,7 +1043,9 @@ class RichTextElement extends AbstractFormElement {
 	 * @return array Label keys and values
 	 */
 	protected function getMergedLabelsFromFile($fileName) {
-		$localizationArray = GeneralUtility::readLLfile($fileName, $this->language, 'utf-8', 1);
+		/** @var $languageFactory LocalizationFactory */
+		$languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
+		$localizationArray = $languageFactory->getParsedData($fileName, $this->language, 'utf-8', 1);
 		if (is_array($localizationArray) && !empty($localizationArray)) {
 			if (!empty($localizationArray[$this->language])) {
 				$finalLocalLang = $localizationArray['default'];
-- 
GitLab