From c42211928142ec9b9835c5e433256ac152527ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hyacinthe=20Compaor=C3=A9?= <131278191+compaoreh338@users.noreply.github.com> Date: Wed, 3 Dec 2025 09:13:47 +0000 Subject: [PATCH 1/9] FEATURE: compatibility v13 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index dac34e0..841f604 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } }, "require": { - "typo3/cms-core": "^12", + "typo3/cms-core": "^12 || ^13", "michelf/php-markdown": "^1.9" } } \ No newline at end of file From 12bb6f4d1f37ce703219331df03c5f2b56c4032c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hyacinthe=20Compaor=C3=A9?= <131278191+compaoreh338@users.noreply.github.com> Date: Thu, 4 Dec 2025 09:59:45 +0000 Subject: [PATCH 2/9] FIX: sanitize output with htmlspecialchars --- Classes/ViewHelpers/Form/ShowViewHelper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/ViewHelpers/Form/ShowViewHelper.php b/Classes/ViewHelpers/Form/ShowViewHelper.php index 8c868b1..d837164 100644 --- a/Classes/ViewHelpers/Form/ShowViewHelper.php +++ b/Classes/ViewHelpers/Form/ShowViewHelper.php @@ -67,8 +67,8 @@ public function render(): string %s ', - $this->getLabel($key, $labelsIn, $labelPrefix), - $value + htmlspecialchars($this->getLabel($key, $labelsIn, $labelPrefix), ENT_QUOTES, 'UTF-8'), + nl2br(htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8')) ); } From a23f2e63383affe0a7fc78846a5f87e047cef03c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hyacinthe=20Compaor=C3=A9?= <131278191+compaoreh338@users.noreply.github.com> Date: Tue, 9 Dec 2025 21:20:52 +0000 Subject: [PATCH 3/9] FIX: warnings --- Classes/TypeConverter/ValuesConverter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/TypeConverter/ValuesConverter.php b/Classes/TypeConverter/ValuesConverter.php index e66cdac..ba28f49 100644 --- a/Classes/TypeConverter/ValuesConverter.php +++ b/Classes/TypeConverter/ValuesConverter.php @@ -46,11 +46,11 @@ public function __construct(ArgumentService $argumentService) * @param string $source * @param string $targetType * @param array $convertedChildProperties - * @param PropertyMappingConfigurationInterface $configuration + * @param PropertyMappingConfigurationInterface|null $configuration * @return array * @api */ - public function convertFrom($source, string $targetType, array $convertedChildProperties = array(), ?PropertyMappingConfigurationInterface $configuration = NULL) + public function convertFrom($source, string $targetType, array $convertedChildProperties = [], ?PropertyMappingConfigurationInterface $configuration = null): array { return $this->getArgumentService()->getValues($source); } From 4de04c0922ea86aed93082cfa5ccfd0c47858d05 Mon Sep 17 00:00:00 2001 From: Lebeau VALANGUI <162180980+Lebeau09@users.noreply.github.com> Date: Mon, 15 Dec 2025 11:32:38 +0000 Subject: [PATCH 4/9] FIX: use numeric 303 status code instead of constant --- Classes/Controller/FormController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Controller/FormController.php b/Classes/Controller/FormController.php index 3d9f2fd..1812f2a 100644 --- a/Classes/Controller/FormController.php +++ b/Classes/Controller/FormController.php @@ -160,7 +160,7 @@ public function submitAction(array $values = []): \Psr\Http\Message\ResponseInte if ($templateService->hasRedirect() && !$templateService->isDefaultRedirectAction()) { $url = $templateService->getRedirectUrl($values); - $response = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Psr\Http\Message\ResponseFactoryInterface::class)->createResponse(\TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303)->withAddedHeader('location', $url); + $response = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Psr\Http\Message\ResponseFactoryInterface::class)->createResponse(303)->withAddedHeader('location', $url); throw new \TYPO3\CMS\Core\Http\PropagateResponseException($response, 8556426865); } else { return $this->redirect( From e5ca53941abf516c9eeabd0a267f26713ac8ad23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hyacinthe=20Compaor=C3=A9?= <131278191+compaoreh338@users.noreply.github.com> Date: Mon, 9 Mar 2026 16:10:49 +0000 Subject: [PATCH 5/9] FIX:bugs --- Classes/Service/ArgumentService.php | 2 +- Classes/Service/FlashMessageQueue.php | 40 +++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/Classes/Service/ArgumentService.php b/Classes/Service/ArgumentService.php index c5339b4..b3181d9 100644 --- a/Classes/Service/ArgumentService.php +++ b/Classes/Service/ArgumentService.php @@ -95,7 +95,7 @@ protected function getRecord($identifier) ); $record = $query - ->execute() + ->executeQuery() ->fetchAssociative(); return $record; diff --git a/Classes/Service/FlashMessageQueue.php b/Classes/Service/FlashMessageQueue.php index 99c8369..7dcbea5 100644 --- a/Classes/Service/FlashMessageQueue.php +++ b/Classes/Service/FlashMessageQueue.php @@ -27,6 +27,13 @@ class FlashMessageQueue implements SingletonInterface */ protected $messages = []; + /** + * In-memory fallback when no frontend user session is available (e.g. CLI or before TSFE init). + * + * @var array> + */ + private static $memoryFallback = []; + /** * @param string $message */ @@ -68,7 +75,12 @@ protected function setMessage(string $severity, string $message) 'text' => $message ]; - $this->getFrontendUser()->setAndSaveSessionData($this->getKey(), $messages); + $feUser = $this->getFrontendUser(); + if ($feUser !== null) { + $feUser->setAndSaveSessionData($this->getKey(), $messages); + } else { + self::$memoryFallback[$this->getKey()] = $messages; + } } /** @@ -76,7 +88,11 @@ protected function setMessage(string $severity, string $message) */ public function getMessages(): array { - return $this->getFrontendUser()->getKey('ses', $this->getKey()) ?? []; + $feUser = $this->getFrontendUser(); + if ($feUser !== null) { + return $feUser->getKey('ses', $this->getKey()) ?? []; + } + return self::$memoryFallback[$this->getKey()] ?? []; } /** @@ -85,8 +101,15 @@ public function getMessages(): array public function getMessagesAndFlush(): array { $messages = $this->getMessages(); - - $this->getFrontendUser()->setAndSaveSessionData($this->getKey(), []); + $feUser = $this->getFrontendUser(); + if ($feUser !== null) { + $feUser->setAndSaveSessionData($this->getKey(), []); + } else { + $key = $this->getKey(); + if (isset(self::$memoryFallback[$key])) { + unset(self::$memoryFallback[$key]); + } + } return $messages; } @@ -98,9 +121,14 @@ protected function getKey(): string return 'formule-flush-messages-' . $this->getTemplateService()->getTemplateIdentifier(); } - protected function getFrontendUser(): FrontendUserAuthentication + protected function getFrontendUser(): ?FrontendUserAuthentication { - return $GLOBALS['TSFE']->fe_user; + $tsfe = $GLOBALS['TSFE'] ?? null; + if (!is_object($tsfe) || !isset($tsfe->fe_user)) { + return null; + } + $feUser = $tsfe->fe_user; + return $feUser instanceof FrontendUserAuthentication ? $feUser : null; } protected function getTemplateService(): TemplateService From bbbe03bdc760dc22eb6edec57c951edd725b39ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Compaor=C3=A9=20Sountong-Noma=20Hyacinthe?= <131278191+compaoreh338@users.noreply.github.com> Date: Thu, 9 Apr 2026 15:09:23 +0000 Subject: [PATCH 6/9] FIX: bugs during plugin use --- .../FormuleRenderEmailAdminBodyElement.php | 2 +- .../Backend/FormuleRenderEmailFromElement.php | 2 +- .../FormuleRenderEmailUserBodyElement.php | 2 +- .../Backend/FormuleRenderFeedbackElement.php | 2 +- .../Backend/FormuleRenderNameFromElement.php | 2 +- .../Backend/FormuleRenderSummaryElement.php | 2 +- Classes/Service/TypoScriptService.php | 23 ++++++++++++------- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Classes/Backend/FormuleRenderEmailAdminBodyElement.php b/Classes/Backend/FormuleRenderEmailAdminBodyElement.php index 68252fa..31afece 100644 --- a/Classes/Backend/FormuleRenderEmailAdminBodyElement.php +++ b/Classes/Backend/FormuleRenderEmailAdminBodyElement.php @@ -7,7 +7,7 @@ class FormuleRenderEmailAdminBodyElement extends AbstractFormuleElement { - public function render() + public function render(): array { // Custom TCA properties and other data can be found in $this->data, for example the above // parameters are available in $this->data['parameterArray']['fieldConf']['config']['parameters'] diff --git a/Classes/Backend/FormuleRenderEmailFromElement.php b/Classes/Backend/FormuleRenderEmailFromElement.php index dd6f3c2..acc7cc9 100644 --- a/Classes/Backend/FormuleRenderEmailFromElement.php +++ b/Classes/Backend/FormuleRenderEmailFromElement.php @@ -6,7 +6,7 @@ class FormuleRenderEmailFromElement extends AbstractFormuleElement { - public function render() + public function render(): array { // Custom TCA properties and other data can be found in $this->data, for example the above // parameters are available in $this->data['parameterArray']['fieldConf']['config']['parameters'] diff --git a/Classes/Backend/FormuleRenderEmailUserBodyElement.php b/Classes/Backend/FormuleRenderEmailUserBodyElement.php index 6091226..91b1634 100644 --- a/Classes/Backend/FormuleRenderEmailUserBodyElement.php +++ b/Classes/Backend/FormuleRenderEmailUserBodyElement.php @@ -6,7 +6,7 @@ class FormuleRenderEmailUserBodyElement extends AbstractFormuleElement { - public function render() + public function render(): array { // Custom TCA properties and other data can be found in $this->data, for example the above // parameters are available in $this->data['parameterArray']['fieldConf']['config']['parameters'] diff --git a/Classes/Backend/FormuleRenderFeedbackElement.php b/Classes/Backend/FormuleRenderFeedbackElement.php index e277958..db41ec1 100644 --- a/Classes/Backend/FormuleRenderFeedbackElement.php +++ b/Classes/Backend/FormuleRenderFeedbackElement.php @@ -6,7 +6,7 @@ class FormuleRenderFeedbackElement extends AbstractFormuleElement { - public function render() + public function render(): array { // Custom TCA properties and other data can be found in $this->data, for example the above // parameters are available in $this->data['parameterArray']['fieldConf']['config']['parameters'] diff --git a/Classes/Backend/FormuleRenderNameFromElement.php b/Classes/Backend/FormuleRenderNameFromElement.php index 75c52c4..d9ce09a 100644 --- a/Classes/Backend/FormuleRenderNameFromElement.php +++ b/Classes/Backend/FormuleRenderNameFromElement.php @@ -6,7 +6,7 @@ class FormuleRenderNameFromElement extends AbstractFormuleElement { - public function render() + public function render(): array { // Custom TCA properties and other data can be found in $this->data, for example the above // parameters are available in $this->data['parameterArray']['fieldConf']['config']['parameters'] diff --git a/Classes/Backend/FormuleRenderSummaryElement.php b/Classes/Backend/FormuleRenderSummaryElement.php index 363a45c..de188d4 100644 --- a/Classes/Backend/FormuleRenderSummaryElement.php +++ b/Classes/Backend/FormuleRenderSummaryElement.php @@ -4,7 +4,7 @@ class FormuleRenderSummaryElement extends AbstractFormuleElement { - public function render() + public function render(): array { // Custom TCA properties and other data can be found in $this->data, for example the above // parameters are available in $this->data['parameterArray']['fieldConf']['config']['parameters'] diff --git a/Classes/Service/TypoScriptService.php b/Classes/Service/TypoScriptService.php index 7776006..dc91289 100644 --- a/Classes/Service/TypoScriptService.php +++ b/Classes/Service/TypoScriptService.php @@ -8,6 +8,7 @@ * LICENSE.md file that was distributed with this source code. */ +use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Http\ApplicationType; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -18,6 +19,10 @@ */ class TypoScriptService implements SingletonInterface { + /** + * Public DI alias id, see Configuration/Services.yaml + */ + private const BACKEND_CONFIGURATION_MANAGER_SERVICE_ID = 'fab.formule.backend_configuration_manager'; /** * @var array @@ -37,13 +42,15 @@ public function getSettings(): array if ($this->isFrontendMode()) { $this->settings = GeneralUtility::removeDotsFromTS($GLOBALS['TYPO3_REQUEST']->getAttribute('frontend.typoscript')->getSetupArray()['plugin.']['tx_formule.']['settings.']); } else { + $request = $GLOBALS['TYPO3_REQUEST'] ?? null; + if ($request instanceof ServerRequestInterface) { + $setup = $this->resolveBackendConfigurationManager()->getTypoScriptSetup($request); + if (is_array($setup['plugin.']['tx_formule.'])) { - $setup = $this->getConfigurationManager()->getTypoScriptSetup(); - if (is_array($setup['plugin.']['tx_formule.'])) { - - /** @var \TYPO3\CMS\Core\TypoScript\TypoScriptService $typoScriptService */ - $typoScriptService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\TypoScriptService::class); - $this->settings = $typoScriptService->convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_formule.']['settings.']); + /** @var \TYPO3\CMS\Core\TypoScript\TypoScriptService $typoScriptService */ + $typoScriptService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\TypoScriptService::class); + $this->settings = $typoScriptService->convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_formule.']['settings.']); + } } } } @@ -51,9 +58,9 @@ public function getSettings(): array return $this->settings; } - protected function getConfigurationManager(): BackendConfigurationManager + protected function resolveBackendConfigurationManager(): BackendConfigurationManager { - return GeneralUtility::makeInstance(BackendConfigurationManager::class); + return GeneralUtility::getContainer()->get(self::BACKEND_CONFIGURATION_MANAGER_SERVICE_ID); } protected function isFrontendMode(): bool From 92e3f1e853bf867de515e54118abe1168db75a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Compaor=C3=A9=20Sountong-Noma=20Hyacinthe?= <131278191+compaoreh338@users.noreply.github.com> Date: Fri, 17 Apr 2026 10:46:23 +0000 Subject: [PATCH 7/9] FIX: Change execute to executeQuery --- Classes/Loader/UserDataLoader.php | 2 +- Classes/Service/DataService.php | 2 +- Classes/Validator/EmailUniqueValidator.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/Loader/UserDataLoader.php b/Classes/Loader/UserDataLoader.php index 8631fc4..1f92801 100644 --- a/Classes/Loader/UserDataLoader.php +++ b/Classes/Loader/UserDataLoader.php @@ -43,7 +43,7 @@ public function load(array $values): array ); $record = $query - ->execute() + ->executeQuery() ->fetchAssociative(); $fields = $this->getTemplateService()->getFields(); diff --git a/Classes/Service/DataService.php b/Classes/Service/DataService.php index 8a565ab..404002c 100644 --- a/Classes/Service/DataService.php +++ b/Classes/Service/DataService.php @@ -151,7 +151,7 @@ public function recordExists(): bool ); $record = $query - ->execute() + ->executeQuery() ->fetchAssociative(); } diff --git a/Classes/Validator/EmailUniqueValidator.php b/Classes/Validator/EmailUniqueValidator.php index 2988506..6eec40f 100644 --- a/Classes/Validator/EmailUniqueValidator.php +++ b/Classes/Validator/EmailUniqueValidator.php @@ -70,7 +70,7 @@ public function validate(array $values): array } $record = $query - ->execute() + ->executeQuery() ->fetchAssociative(); if (!empty($record)) { From b1cd3bea5a29b589df01794bdd80c6a3d24a78fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Compaor=C3=A9=20Sountong-Noma=20Hyacinthe?= <131278191+compaoreh338@users.noreply.github.com> Date: Fri, 17 Apr 2026 11:03:38 +0000 Subject: [PATCH 8/9] FIX: fix errors --- Classes/Controller/FormController.php | 2 +- Classes/Service/DataService.php | 25 ++++++++++++++++++++++ Classes/Service/TemplateService.php | 30 ++++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/Classes/Controller/FormController.php b/Classes/Controller/FormController.php index 1812f2a..e76790f 100644 --- a/Classes/Controller/FormController.php +++ b/Classes/Controller/FormController.php @@ -158,7 +158,7 @@ public function submitAction(array $values = []): \Psr\Http\Message\ResponseInte $this->getRegistryService()->set('values', $values); if ($templateService->hasRedirect() && !$templateService->isDefaultRedirectAction()) { - $url = $templateService->getRedirectUrl($values); + $url = $templateService->getRedirectUrl($values, $this->request); $response = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Psr\Http\Message\ResponseFactoryInterface::class)->createResponse(303)->withAddedHeader('location', $url); throw new \TYPO3\CMS\Core\Http\PropagateResponseException($response, 8556426865); diff --git a/Classes/Service/DataService.php b/Classes/Service/DataService.php index 404002c..b8cc2d7 100644 --- a/Classes/Service/DataService.php +++ b/Classes/Service/DataService.php @@ -55,6 +55,7 @@ public function create(array $values) $tableName = $this->getTemplateService()->getPersistingTable(); $connection = $this->getConnection($tableName); + $finalValues = $this->filterValuesToExistingTableColumns($connection, $tableName, $finalValues); $connection->insert( $tableName, $finalValues @@ -93,6 +94,7 @@ public function update(array $values): array $tableName = $this->getTemplateService()->getPersistingTable(); $connection = $this->getConnection($tableName); + $finalValues = $this->filterValuesToExistingTableColumns($connection, $tableName, $finalValues); $connection->update( $tableName, @@ -212,6 +214,29 @@ protected function getSanitizedValues(array $values): array return $sanitizedValues; } + /** + * Keep only keys that exist as real columns on the table. TCA may define fields before the DB is migrated. + * + * @param array $values + * @return array + */ + protected function filterValuesToExistingTableColumns(Connection $connection, string $tableName, array $values): array + { + if ($tableName === '' || $values === []) { + return $values; + } + + $existingColumns = array_flip($connection->getSchemaInformation()->listTableColumnNames($tableName)); + $filtered = []; + foreach ($values as $key => $value) { + if (isset($existingColumns[$key])) { + $filtered[$key] = $value; + } + } + + return $filtered; + } + /** * @return array */ diff --git a/Classes/Service/TemplateService.php b/Classes/Service/TemplateService.php index 5097164..87a9df6 100644 --- a/Classes/Service/TemplateService.php +++ b/Classes/Service/TemplateService.php @@ -8,10 +8,14 @@ * LICENSE.md file that was distributed with this source code. */ +use Psr\Http\Message\ServerRequestInterface; use RuntimeException; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters; +use TYPO3\CMS\Extbase\Mvc\Request as ExtbaseRequest; +use TYPO3\CMS\Extbase\Mvc\RequestInterface; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; /** @@ -148,9 +152,10 @@ public function isDefaultRedirectAction(): bool /** * @param array $values + * @param RequestInterface|null $request Current Extbase request (required for UriBuilder on TYPO3 12+). * @return string */ - public function getRedirectUrl(array $values): string + public function getRedirectUrl(array $values, ?RequestInterface $request = null): string { $arguments = []; @@ -161,6 +166,7 @@ public function getRedirectUrl(array $values): string } $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); + $uriBuilder->setRequest($this->resolveExtbaseRequestForUriBuilder($request)); $uriBuilder = $uriBuilder ->reset() ->setCreateAbsoluteUri(true) @@ -173,6 +179,28 @@ public function getRedirectUrl(array $values): string return $uriBuilder->build(); } + /** + * UriBuilder::build() requires an Extbase request (TYPO3 12+). + */ + protected function resolveExtbaseRequestForUriBuilder(?RequestInterface $request): RequestInterface + { + if ($request !== null) { + return $request; + } + + $serverRequest = $GLOBALS['TYPO3_REQUEST'] ?? null; + if ($serverRequest instanceof ServerRequestInterface + && $serverRequest->getAttribute('extbase') instanceof ExtbaseRequestParameters + ) { + return new ExtbaseRequest($serverRequest); + } + + throw new RuntimeException( + 'Formule TemplateService::getRedirectUrl() needs an Extbase request: pass the controller request or run in a frontend Extbase context.', + 1739120400 + ); + } + /** * @return int|null */ From 554f42ca0baee8ecd91018495bac45aecd13069e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Compaor=C3=A9=20Sountong-Noma=20Hyacinthe?= <131278191+compaoreh338@users.noreply.github.com> Date: Fri, 17 Apr 2026 11:19:45 +0000 Subject: [PATCH 9/9] FIX: fix templates tablenames --- Classes/Service/TemplateService.php | 45 +++++++++++++++++++---------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/Classes/Service/TemplateService.php b/Classes/Service/TemplateService.php index 87a9df6..0771271 100644 --- a/Classes/Service/TemplateService.php +++ b/Classes/Service/TemplateService.php @@ -111,8 +111,11 @@ public function getResolvedPath(): string public function getPersistingTableName(): string { $persist = $this->get('persist'); - $tableName = is_array($persist) && empty($persist['tableName']) ? '' : $persist['tableName']; - return $tableName; + if (!is_array($persist)) { + return ''; + } + + return (string)($persist['tableName'] ?? ''); } /** @@ -121,8 +124,12 @@ public function getPersistingTableName(): string public function getIdentifierField(): string { $persist = $this->get('persist'); - $identifierField = is_array($persist) && empty($persist['identifierField']) ? 'uid' : $persist['identifierField']; - return $identifierField; + if (!is_array($persist)) { + return 'uid'; + } + $identifierField = $persist['identifierField'] ?? ''; + + return $identifierField !== '' ? (string)$identifierField : 'uid'; } /** @@ -245,10 +252,12 @@ public function hasWarnings(): bool public function getDefaultValues(): array { $persist = $this->get('persist'); + if (!is_array($persist) || empty($persist['defaultValues'])) { + return []; + } + $defaultValues = $persist['defaultValues']; - $defaultValues = is_array($persist) && empty($persist['defaultValues']) ? [] : $persist['defaultValues']; - - return $defaultValues; + return is_array($defaultValues) ? $defaultValues : []; } /** @@ -257,8 +266,11 @@ public function getDefaultValues(): array public function getMappings(): array { $persist = $this->get('persist'); - - $mappings = is_array($persist) && empty($persist['mappings']) ? [] : $persist['mappings']; + if (!is_array($persist) || empty($persist['mappings'])) { + $mappings = []; + } else { + $mappings = is_array($persist['mappings']) ? $persist['mappings'] : []; + } $ts = $this->getTypoScriptService()->getSettings(); $tableName = $this->getPersistingTableName(); @@ -304,8 +316,12 @@ public function getWarnings(): array public function getProcessors(): array { $persist = $this->get('persist'); - $processors = is_array($persist) && empty($persist['processors']) ? [] : $persist['processors']; - return $processors; + if (!is_array($persist) || empty($persist['processors'])) { + return []; + } + $processors = $persist['processors']; + + return is_array($processors) ? $processors : []; } /** @@ -399,13 +415,12 @@ public function getFields(): array public function getPreferredEmailBodyEncoding(): string { $preferEmailBodyEncoding = $this->get('preferEmailBodyEncoding'); - if (is_null($preferEmailBodyEncoding)) { - + if ($preferEmailBodyEncoding === null || $preferEmailBodyEncoding === '') { $ts = $this->getTypoScriptService()->getSettings(); - $preferEmailBodyEncoding = $ts['preferEmailBodyEncoding']; + $preferEmailBodyEncoding = $ts['preferEmailBodyEncoding'] ?? 'html'; } - return $preferEmailBodyEncoding; + return (string)$preferEmailBodyEncoding; } /**