From 11eb389aadda5c96e7a8251b4e737269e6191284 Mon Sep 17 00:00:00 2001 From: Francois Suter <sutfra@gmail.com> Date: Mon, 4 Jul 2022 16:54:00 +0200 Subject: [PATCH] [BUGFIX] Avoid undefined array key access in DataMapFactory In two places \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory accesses the TCA for some table without checking if it exists. Resolves: #97853 Releases: main, 11.5 Change-Id: I02c46153013c920cc771f085f872004e9a22ab3c Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75025 Tested-by: core-ci <typo3@b13.com> Tested-by: Simon Schaufelberger <simonschaufi+typo3@gmail.com> Tested-by: Markus Klein <markus.klein@typo3.org> Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Simon Schaufelberger <simonschaufi+typo3@gmail.com> Reviewed-by: Markus Klein <markus.klein@typo3.org> Reviewed-by: Benni Mack <benni@typo3.org> --- .../Classes/Persistence/Generic/Mapper/DataMapFactory.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php index fdab907ab770..330b017ade5a 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php +++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapFactory.php @@ -210,7 +210,7 @@ class DataMapFactory implements SingletonInterface */ protected function getColumnsDefinition(string $tableName): array { - return is_array($GLOBALS['TCA'][$tableName]['columns']) ? $GLOBALS['TCA'][$tableName]['columns'] : []; + return is_array($GLOBALS['TCA'][$tableName]['columns'] ?? null) ? $GLOBALS['TCA'][$tableName]['columns'] : []; } /** @@ -220,7 +220,10 @@ class DataMapFactory implements SingletonInterface */ protected function addMetaDataColumnNames(DataMap $dataMap, string $tableName): DataMap { - $controlSection = $GLOBALS['TCA'][$tableName]['ctrl']; + $controlSection = $GLOBALS['TCA'][$tableName]['ctrl'] ?? null; + if ($controlSection === null) { + return $dataMap; + } $dataMap->setPageIdColumnName('pid'); if (isset($controlSection['tstamp'])) { $dataMap->setModificationDateColumnName($controlSection['tstamp']); -- GitLab