[!!!][TASK] Remove deprecated code from DatabaseRowInitializeNew 60/59460/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 16 Jan 2019 19:22:28 +0000 (20:22 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 17 Jan 2019 09:43:21 +0000 (10:43 +0100)
Resolves: #87463
Releases: master
Change-Id: I48cce7cea659036e58c1119fee4b4737df67ffbe
Reviewed-on: https://review.typo3.org/59460
Tested-by: TYPO3com <noreply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Form/FormDataProvider/DatabaseRowInitializeNew.php
typo3/sysext/backend/Tests/UnitDeprecated/Form/FormDataProvider/DatabaseRowInitializeNewTest.php [deleted file]

index a3d7c13..4ce2c47 100644 (file)
@@ -131,7 +131,6 @@ class DatabaseRowInitializeNew implements FormDataProviderInterface
      */
     protected function setDefaultsFromDefaultValues(array $result)
     {
-        $result = $this->setDefaultValuesFromGetPost($result);
         $tableName = $result['tableName'];
         $defaultValues = $result['defaultValues'] ?? [];
         if (isset($defaultValues[$tableName]) && is_array($defaultValues[$tableName])) {
@@ -145,30 +144,6 @@ class DatabaseRowInitializeNew implements FormDataProviderInterface
     }
 
     /**
-     * @param array $result
-     * @return array
-     * @deprecated since TYPO3 v9 will be removed in TYPO3 v10.0 - see $result['defaultValues']
-     */
-    protected function setDefaultValuesFromGetPost(array $result)
-    {
-        if (!empty($result['defaultValues'])) {
-            return $result;
-        }
-
-        $defaultValues = GeneralUtility::_GP('defVals');
-        if (!empty($defaultValues)) {
-            trigger_error(
-                'Default values for new database rows should be set from controller context. Applying default values'
-                . ' via GET/POST parameters is deprecated since 9.2 and will be removed in version 10',
-                E_USER_DEPRECATED
-            );
-            $result['defaultValues'] = $defaultValues;
-        }
-
-        return $result;
-    }
-
-    /**
      * Inline scenario if a new intermediate record to an existing child-child is
      * compiled. Set "foreign_selector" field of this intermediate row to given
      * "childChildUid". See TcaDataCompiler array comment of inlineChildChildUid
diff --git a/typo3/sysext/backend/Tests/UnitDeprecated/Form/FormDataProvider/DatabaseRowInitializeNewTest.php b/typo3/sysext/backend/Tests/UnitDeprecated/Form/FormDataProvider/DatabaseRowInitializeNewTest.php
deleted file mode 100644 (file)
index 0ff57b4..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-<?php
-declare(strict_types = 1);
-namespace TYPO3\CMS\Backend\Tests\UnitDeprecated\Form\FormDataProvider;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowInitializeNew;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
-
-/**
- * Test case for TcaFlexPrepare to render the functionality when a TCA migration happened
- */
-class DatabaseRowInitializeNewTest extends UnitTestCase
-{
-    /**
-     * @test
-     */
-    public function addDataSetsDefaultDataFromGetIfColumnIsDefinedInTca()
-    {
-        $input = [
-            'command' => 'new',
-            'tableName' => 'aTable',
-            'vanillaUid' => 23,
-            'neighborRow' => null,
-            'inlineChildChildUid' => null,
-            'isInlineChild' => false,
-            'databaseRow' => [],
-            'processedTca' => [
-                'columns' => [
-                    'aField' => [],
-                ],
-            ],
-        ];
-        $GLOBALS['_GET'] = [
-            'defVals' => [
-                'aTable' => [
-                    'aField' => 'getValue',
-                ],
-            ],
-        ];
-        $expected = [
-            'aField' => 'getValue',
-            'pid' => 23,
-        ];
-        $result = (new DatabaseRowInitializeNew())->addData($input);
-        $this->assertSame($expected, $result['databaseRow']);
-    }
-
-    /**
-     * @test
-     */
-    public function addDataSetsDefaultDataFromPostIfColumnIsDefinedInTca()
-    {
-        $input = [
-            'command' => 'new',
-            'tableName' => 'aTable',
-            'vanillaUid' => 23,
-            'neighborRow' => null,
-            'inlineChildChildUid' => null,
-            'isInlineChild' => false,
-            'databaseRow' => [],
-            'processedTca' => [
-                'columns' => [
-                    'aField' => [],
-                ],
-            ],
-        ];
-        $GLOBALS['_POST'] = [
-            'defVals' => [
-                'aTable' => [
-                    'aField' => 'postValue',
-                ],
-            ],
-        ];
-        $expected = [
-            'aField' => 'postValue',
-            'pid' => 23,
-        ];
-        $result = (new DatabaseRowInitializeNew())->addData($input);
-        $this->assertSame($expected, $result['databaseRow']);
-    }
-
-    /**
-     * @test
-     */
-    public function addDataSetsPrioritizesDefaultPostOverDefaultGet()
-    {
-        $input = [
-            'command' => 'new',
-            'tableName' => 'aTable',
-            'vanillaUid' => 23,
-            'neighborRow' => null,
-            'inlineChildChildUid' => null,
-            'isInlineChild' => false,
-            'databaseRow' => [],
-            'processedTca' => [
-                'columns' => [
-                    'aField' => [],
-                ],
-            ],
-        ];
-        $GLOBALS['_GET'] = [
-            'defVals' => [
-                'aTable' => [
-                    'aField' => 'getValue',
-                ],
-            ],
-        ];
-        $GLOBALS['_POST'] = [
-            'defVals' => [
-                'aTable' => [
-                    'aField' => 'postValue',
-                ],
-            ],
-        ];
-        $expected = [
-            'aField' => 'postValue',
-            'pid' => 23,
-        ];
-        $result = (new DatabaseRowInitializeNew())->addData($input);
-        $this->assertSame($expected, $result['databaseRow']);
-    }
-
-    /**
-     * @test
-     */
-    public function addDataDoesNotSetDefaultDataFromGetPostIfColumnIsMissingInTca()
-    {
-        $input = [
-            'command' => 'new',
-            'tableName' => 'aTable',
-            'vanillaUid' => 23,
-            'neighborRow' => null,
-            'inlineChildChildUid' => null,
-            'isInlineChild' => false,
-            'databaseRow' => [],
-            'userTsConfig' => [
-                'TCAdefaults.' => [
-                    'aTable.' => [
-                        'aField' => 'pageTsValue',
-                    ],
-                ],
-            ],
-            'processedTca' => [
-                'columns' => [],
-            ],
-        ];
-        $GLOBALS['_GET'] = [
-            'defVals' => [
-                'aTable' => [
-                    'aField' => 'getValue',
-                ],
-            ],
-        ];
-        $GLOBALS['_POST'] = [
-            'defVals' => [
-                'aTable' => [
-                    'aField' => 'postValue',
-                ],
-            ],
-        ];
-        $expected = [
-            'pid' => 23,
-        ];
-        $result = (new DatabaseRowInitializeNew())->addData($input);
-        $this->assertSame($expected, $result['databaseRow']);
-    }
-
-    /**
-     * @test
-     */
-    public function addDataSetsDefaultDataOverrulingGetPost()
-    {
-        $input = [
-            'command' => 'new',
-            'tableName' => 'aTable',
-            'vanillaUid' => 23,
-            'inlineChildChildUid' => null,
-            'isInlineChild' => false,
-            'databaseRow' => [],
-            'neighborRow' => [
-                'aField' => 'valueFromNeighbor',
-            ],
-            'pageTsConfig' => [
-                'TCAdefaults.' => [
-                    'aTable.' => [
-                        'aField' => 'pageTsValue',
-                    ],
-                ],
-            ],
-            'userTsConfig' => [
-                'TCAdefaults.' => [
-                    'aTable.' => [
-                        'aField' => 'userTsValue',
-                    ],
-                ],
-            ],
-            'processedTca' => [
-                'ctrl' => [
-                    'useColumnsForDefaultValues' => 'aField',
-                ],
-                'columns' => [
-                    'aField' => [],
-                ],
-            ],
-        ];
-        $GLOBALS['_POST'] = [
-            'defVals' => [
-                'aTable' => [
-                    'aField' => 'postValue',
-                ],
-            ],
-        ];
-        $expected = [
-            'aField' => 'postValue',
-            'pid' => 23,
-        ];
-        $result = (new DatabaseRowInitializeNew())->addData($input);
-        $this->assertSame($expected, $result['databaseRow']);
-    }
-}