Skip to content

Commit

Permalink
[BUGFIX] Fatal in ext:form using LanguageServiceFactory
Browse files Browse the repository at this point in the history
Patch #94414 broke a case in ext:form leading to a
fatal, easily reproducible when opening a content
element having a form.
The class is internal and only used in backend
through a hook and can thus rely on GLOBALS['LANG']
like so many other backend classes do.

Resolves: #94429
Related: #94414
Releases: master
Change-Id: I578d3b1d61894c210bb0fb20cddf44307cb40ae2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69653
Tested-by: Benni Mack <benni@typo3.org>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Jochen <rothjochen@gmail.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
lolli42 committed Jun 29, 2021
1 parent c7745b1 commit f0d038e
Showing 1 changed file with 9 additions and 20 deletions.
Expand Up @@ -17,10 +17,9 @@

namespace TYPO3\CMS\Form\Domain\Configuration\FlexformConfiguration\Processors;

use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Generate a FlexForm element for a finisher option
Expand All @@ -29,22 +28,6 @@
*/
class FinisherOptionGenerator extends AbstractProcessor
{
/**
* @var \TYPO3\CMS\Core\Localization\LanguageServiceFactory
*/
protected $languageService;

/**
* @param ProcessorDto $converterDto
*/
public function __construct(ProcessorDto $converterDto)
{
parent::__construct($converterDto);

$this->languageService = GeneralUtility::makeInstance(LanguageServiceFactory::class);
$this->languageService->includeLLFile('EXT:form/Resources/Private/Language/Database.xlf');
}

/**
* @param string $_ unused in this context
* @param mixed $__ unused in this context
Expand Down Expand Up @@ -89,10 +72,11 @@ public function __invoke(string $_, $__, array $matches)
} catch (MissingArrayPathException $exception) {
}

$languageService = $this->getLanguageService();
if (empty($optionValue)) {
$elementConfiguration['label'] .= sprintf(' (%s: "%s")', $this->languageService->getLL('default'), $this->languageService->getLL('empty'));
$elementConfiguration['label'] .= sprintf(' (%s: "%s")', $languageService->getLL('default'), $languageService->getLL('empty'));
} else {
$elementConfiguration['label'] .= sprintf(' (%s: "' . $optionValue . '")', $this->languageService->getLL('default'));
$elementConfiguration['label'] .= sprintf(' (%s: "' . $optionValue . '")', $languageService->getLL('default'));
}

if (isset($elementConfiguration['config'])) {
Expand All @@ -104,4 +88,9 @@ public function __invoke(string $_, $__, array $matches)

$this->converterDto->setResult($sheetElements);
}

protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
}

0 comments on commit f0d038e

Please sign in to comment.