From da4db433a4c0b011ee0d38dc4844be4eaa610b78 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Thu, 15 Feb 2018 02:56:34 +0100 Subject: [PATCH] [BUGFIX] Notice free InlineStackProcessor testing Change-Id: I77a4782f250a4b37051eb321fd5c6670b4366e24 Resolves: #83908 Releases: master Reviewed-on: https://review.typo3.org/55726 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Jan Stockfisch <jan.stockfisch@googlemail.com> Tested-by: Jan Stockfisch <jan.stockfisch@googlemail.com> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> --- .../Classes/Form/InlineStackProcessor.php | 4 +- .../Form/Utility/FormEngineUtility.php | 6 +-- .../Unit/Form/InlineStackProcessorTest.php | 46 +++++++++++-------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/typo3/sysext/backend/Classes/Form/InlineStackProcessor.php b/typo3/sysext/backend/Classes/Form/InlineStackProcessor.php index 0019919cb2a7..276664db01f6 100644 --- a/typo3/sysext/backend/Classes/Form/InlineStackProcessor.php +++ b/typo3/sysext/backend/Classes/Form/InlineStackProcessor.php @@ -72,12 +72,12 @@ class InlineStackProcessor if ($i > 0 && $i % 3 == 0) { // Load the TCA configuration of the table field and store it in the stack // @todo: This TCA loading here must fall - config sub-array shouldn't exist at all! - $unstable['config'] = $GLOBALS['TCA'][$unstable['table']]['columns'][$unstable['field']]['config']; + $unstable['config'] = $GLOBALS['TCA'][$unstable['table']]['columns'][$unstable['field']]['config'] ?? []; // Fetch TSconfig: // @todo: aaargs ;) $TSconfig = FormEngineUtility::getTSconfigForTableRow($unstable['table'], ['uid' => $unstable['uid'], 'pid' => $inlineFirstPid], $unstable['field']); // Override TCA field config by TSconfig: - if (!$TSconfig['disabled']) { + if (!isset($TSconfig['disabled']) || !$TSconfig['disabled']) { $unstable['config'] = FormEngineUtility::overrideFieldConf($unstable['config'], $TSconfig); } diff --git a/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php b/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php index 72ed5018a930..703ae424136b 100644 --- a/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php +++ b/typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php @@ -67,8 +67,8 @@ class FormEngineUtility { if (is_array($TSconfig)) { $TSconfig = GeneralUtility::removeDotsFromTS($TSconfig); - $type = $fieldConfig['type']; - if (is_array($TSconfig['config']) && is_array(static::$allowOverrideMatrix[$type])) { + $type = $fieldConfig['type'] ?? ''; + if (isset($TSconfig['config']) && is_array($TSconfig['config']) && is_array(static::$allowOverrideMatrix[$type])) { // Check if the keys in TSconfig['config'] are allowed to override TCA field config: foreach ($TSconfig['config'] as $key => $_) { if (!in_array($key, static::$allowOverrideMatrix[$type], true)) { @@ -104,7 +104,7 @@ class FormEngineUtility if (!isset($cache[$cacheIdentifier])) { $cache[$cacheIdentifier] = BackendUtility::getTCEFORM_TSconfig($table, $row); } - if ($field) { + if ($field && isset($cache[$cacheIdentifier][$field])) { return $cache[$cacheIdentifier][$field]; } return $cache[$cacheIdentifier]; diff --git a/typo3/sysext/backend/Tests/Unit/Form/InlineStackProcessorTest.php b/typo3/sysext/backend/Tests/Unit/Form/InlineStackProcessorTest.php index e44b6ecb8e2b..661d0d640764 100644 --- a/typo3/sysext/backend/Tests/Unit/Form/InlineStackProcessorTest.php +++ b/typo3/sysext/backend/Tests/Unit/Form/InlineStackProcessorTest.php @@ -1,4 +1,5 @@ <?php +declare(strict_types = 1); namespace TYPO3\CMS\Backend\Tests\Unit\Form; /* @@ -15,17 +16,13 @@ namespace TYPO3\CMS\Backend\Tests\Unit\Form; */ use TYPO3\CMS\Backend\Form\InlineStackProcessor; +use TYPO3\TestingFramework\Core\Unit\UnitTestCase; /** * Test case */ -class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase +class InlineStackProcessorTest extends UnitTestCase { - /** - * Subject is not notice free, disable E_NOTICES - */ - protected static $suppressNotices = true; - /** * @return array */ @@ -39,7 +36,10 @@ class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes 'table' => 'childTable', ], ], - [] + [ + 'form' => '', + 'object' => '', + ] ], 'simple 1-level table-uid structure' => [ 'data-pageId-childTable-childUid', @@ -49,7 +49,10 @@ class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes 'uid' => 'childUid', ], ], - [] + [ + 'form' => '', + 'object' => '', + ] ], 'simple 1-level table-uid-field structure' => [ 'data-pageId-childTable-childUid-childField', @@ -60,7 +63,10 @@ class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes 'field' => 'childField', ], ], - [], + [ + 'form' => '', + 'object' => '', + ], ], 'simple 2-level table structure' => [ 'data-pageId-parentTable-parentUid-parentField-childTable', @@ -70,7 +76,7 @@ class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes 'table' => 'parentTable', 'uid' => 'parentUid', 'field' => 'parentField', - 'config' => null, + 'config' => [], ], ], 'unstable' => [ @@ -90,7 +96,7 @@ class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes 'table' => 'parentTable', 'uid' => 'parentUid', 'field' => 'parentField', - 'config' => null, + 'config' => [], ], ], 'unstable' => [ @@ -111,7 +117,7 @@ class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes 'table' => 'parentTable', 'uid' => 'parentUid', 'field' => 'parentField', - 'config' => null, + 'config' => [], ], ], 'unstable' => [ @@ -133,13 +139,13 @@ class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes 'table' => 'grandParentTable', 'uid' => 'grandParentUid', 'field' => 'grandParentField', - 'config' => null, + 'config' => [], ], [ 'table' => 'parentTable', 'uid' => 'parentUid', 'field' => 'parentField', - 'config' => null, + 'config' => [], ], ], 'unstable' => [ @@ -159,13 +165,13 @@ class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes 'table' => 'grandParentTable', 'uid' => 'grandParentUid', 'field' => 'grandParentField', - 'config' => null, + 'config' => [], ], [ 'table' => 'parentTable', 'uid' => 'parentUid', 'field' => 'parentField', - 'config' => null, + 'config' => [], ], ], 'unstable' => [ @@ -186,13 +192,13 @@ class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes 'table' => 'grandParentTable', 'uid' => 'grandParentUid', 'field' => 'grandParentField', - 'config' => null, + 'config' => [], ], [ 'table' => 'parentTable', 'uid' => 'parentUid', 'field' => 'parentField', - 'config' => null, + 'config' => [], ], ], 'unstable' => [ @@ -217,13 +223,13 @@ class InlineStackProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes 'flexform' => [ 'data', 'sDEF', 'lDEF', 'grandParentFlexForm', 'vDEF', ], - 'config' => null, + 'config' => [], ], [ 'table' => 'parentTable', 'uid' => 'parentUid', 'field' => 'parentField', - 'config' => null, + 'config' => [], ], ], 'unstable' => [ -- GitLab