[TASK] Remove TCA config 'max' on inputDateTime fields 03/51903/7
authorThomas Hohn <thomas@hohn.dk>
Tue, 28 Feb 2017 15:42:39 +0000 (16:42 +0100)
committerFrank Nägler <frank.naegler@typo3.org>
Thu, 9 Mar 2017 08:17:30 +0000 (09:17 +0100)
The TCA migration removes the 'max' config option for
renderType="inputDateTime" since this should not be set
for this renderType to avoid performance issues when
storing data in the DB.

Resolves: #80027
Releases: master
Change-Id: Ia8d6d95e0830c6173522757ece5e3f48db618f33
Reviewed-on: https://review.typo3.org/51903
Reviewed-by: Christer V <cvi@systime.dk>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
typo3/sysext/core/Classes/Migrations/TcaMigration.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-80027-RemoveTCAConfigMaxOnInputDateTimeFields.rst [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Migrations/TcaMigrationTest.php

index 7ac8c62..b7e73a9 100644 (file)
@@ -83,6 +83,7 @@ class TcaMigration
         $tca = $this->migrateOptionsOfTypeGroup($tca);
         $tca = $this->migrateSelectShowIconTable($tca);
         $tca = $this->migrateImageManipulationConfig($tca);
+        $tca = $this->migrateinputDateTimeMax($tca);
         return $tca;
     }
 
@@ -2262,4 +2263,30 @@ class TcaMigration
 
         return $tca;
     }
+
+    /**
+     * Migrate 'max' for renderType='inputDateTime'
+     *
+     * @param array $tca
+     * @return array
+     */
+    protected function migrateinputDateTimeMax(array $tca): array
+    {
+        foreach ($tca as $table => &$tableDefinition) {
+            if (isset($tableDefinition['columns']) && is_array($tableDefinition['columns'])) {
+                foreach ($tableDefinition['columns'] as $fieldName => &$fieldConfig) {
+                    if (isset($fieldConfig['config']['renderType'])) {
+                        if ($fieldConfig['config']['renderType'] === 'inputDateTime') {
+                            if (isset($fieldConfig['config']['max'])) {
+                                unset($fieldConfig['config']['max']);
+                                $this->messages[] = 'The config option \'max\' has been removed from the TCA for renderType=\'inputDateTime\' in ' . $table . '[\'columns\'][\'' . $fieldName . '\'][\'config\'][\'max\']';
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return $tca;
+    }
 }
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80027-RemoveTCAConfigMaxOnInputDateTimeFields.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80027-RemoveTCAConfigMaxOnInputDateTimeFields.rst
new file mode 100644 (file)
index 0000000..4662a7a
--- /dev/null
@@ -0,0 +1,33 @@
+.. include:: ../../Includes.txt
+
+=====================================================================
+Deprecation: #80027 - Remove TCA config 'max' on inputDateTime fields
+=====================================================================
+
+See :issue:`80027`
+
+Description
+===========
+
+The TCA migration removes the 'max' config option for renderType="inputDateTime" since
+this should not be set for this renderType.
+
+
+Impact
+======
+
+Has an impact on performance during saving of records.
+
+
+Affected Installations
+======================
+
+All installations using the 'max' config option for renderType="inputDateTime".
+
+
+Migration
+=========
+
+Remove the 'max' config option for renderType="inputDateTime".
+
+.. index:: Backend, Database
\ No newline at end of file
index 8f7bfa3..4054a64 100644 (file)
@@ -5600,4 +5600,215 @@ class TcaMigrationTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $this->assertEquals($expected, (new TcaMigration())->migrate($input));
     }
+
+    /**
+     * @test
+     */
+    public function migrateinputDateTimeMaxNotDefinedAndRenderTypeNotDefined()
+    {
+        $input = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input'
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $expected = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input'
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $subject = new TcaMigration();
+        $this->assertEquals($expected, $subject->migrate($input));
+    }
+
+    /**
+     * @test
+     */
+    public function migrateinputDateTimeMaxNotDefinedAndRenderTypeNotInputDateTime()
+    {
+        $input = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input',
+                            'renderType' => 'fooBar'
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $expected = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input',
+                            'renderType' => 'fooBar'
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $subject = new TcaMigration();
+        $this->assertEquals($expected, $subject->migrate($input));
+    }
+
+    /**
+     * @test
+     */
+    public function migrateinputDateTimeMaxNotDefined()
+    {
+        $input = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input',
+                            'renderType' => 'inputDateTime'
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $expected = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input',
+                            'renderType' => 'inputDateTime'
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $subject = new TcaMigration();
+        $this->assertEquals($expected, $subject->migrate($input));
+    }
+
+    /**
+     * @test
+     */
+    public function migrateinputDateTimeMaxDefined()
+    {
+        $input = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input',
+                            'renderType' => 'inputDateTime',
+                            'max' => 42,
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $expected = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input',
+                            'renderType' => 'inputDateTime',
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $subject = new TcaMigration();
+        $this->assertEquals($expected, $subject->migrate($input));
+    }
+
+    /**
+     * @test
+     */
+    public function migrateinputDateTimeMaxDefinedAndRenderTypeNotDefined()
+    {
+        $input = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input',
+                            'max' => 42,
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $expected = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input',
+                            'max' => 42,
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $subject = new TcaMigration();
+        $this->assertEquals($expected, $subject->migrate($input));
+    }
+
+    /**
+     * @test
+     */
+    public function migrateinputDateTimeMaxDefinedAndRenderTypeNotDateTime()
+    {
+        $input = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input',
+                            'renderType' => 'fooBar',
+                            'max' => 42,
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $expected = [
+            'aTable' => [
+                'columns' => [
+                    'foo' => [
+                        'config' => [
+                            'type' => 'input',
+                            'renderType' => 'fooBar',
+                            'max' => 42,
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $subject = new TcaMigration();
+        $this->assertEquals($expected, $subject->migrate($input));
+    }
 }