From eb19b7d4ded9d0619da4573cd5a4f07e9cc1dde4 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Tue, 14 Jul 2015 22:26:32 +0200
Subject: [PATCH] [FOLLOWUP][TASK] Deprecate GeneralUtility:readLLfile

ExtensionManager fatals since the parserFactory object is
not always instantiated as expected.

Resolves: #68122
Releases: master
Change-Id: Ibc1ad2ac4df76b80b529c45ab5c1bf83115abf69
Reviewed-on: http://review.typo3.org/41240
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
---
 typo3/sysext/lang/Classes/LanguageService.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/lang/Classes/LanguageService.php b/typo3/sysext/lang/Classes/LanguageService.php
index 2941e3088380..037a303ff8dd 100644
--- a/typo3/sysext/lang/Classes/LanguageService.php
+++ b/typo3/sysext/lang/Classes/LanguageService.php
@@ -407,6 +407,13 @@ class LanguageService {
 	 * @return array value of $LOCAL_LANG found in the included file, empty if non found
 	 */
 	protected function readLLfile($fileRef) {
+		// @todo: Usually, an instance of the LocalizationFactory is found in $this->parserFactory.
+		// @todo: This is not the case if $GLOBALS['LANG'] is not used to get hold of this object,
+		// @todo: but the objectManager instead. If then init() is not called, this will fatal ...
+		// @todo: To be sure, we always create an instance here for now.
+		/** @var $languageFactory LocalizationFactory */
+		$languageFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
+
 		if ($this->lang !== 'default') {
 			$languages = array_reverse($this->languageDependencies);
 		} else {
@@ -414,7 +421,7 @@ class LanguageService {
 		}
 		$localLanguage = array();
 		foreach ($languages as $language) {
-			$tempLL = $this->parserFactory->getParsedData($fileRef, $language, $this->charSet);
+			$tempLL = $languageFactory->getParsedData($fileRef, $language, $this->charSet);
 			$localLanguage['default'] = $tempLL['default'];
 			if (!isset($localLanguage[$this->lang])) {
 				$localLanguage[$this->lang] = $localLanguage['default'];
-- 
GitLab