[BUGFIX] Initialize uploadfolder key for TCA group file_reference 11/53311/5
authorSascha Egerer <sascha@sascha-egerer.de>
Thu, 22 Jun 2017 15:31:59 +0000 (17:31 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 28 Jun 2017 10:53:13 +0000 (12:53 +0200)
The array key 'uploadfolder' is initialized on a non existing array.
It must be initialized on the processed tca array

Resolves: #81681
Releases: master, 8.7
Change-Id: Ied776e4b0d0d4c33cf0894a2c4c95ceb6c03bb18
Reviewed-on: https://review.typo3.org/53311
Reviewed-by: Henrik Elsner <helsner@dfau.de>
Tested-by: Henrik Elsner <helsner@dfau.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaGroup.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaGroupTest.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php

index a1a9b85..5b60b59 100644 (file)
@@ -68,9 +68,9 @@ class TcaGroup implements FormDataProviderInterface
                 if (empty($fieldConfig['config']['allowed'])) {
                     $result['processedTca']['columns'][$fieldName]['config']['allowed'] = '*';
                 }
-                // Force uploadFolder for file_reference type
+                // Force empty uploadfolder for file_reference type
                 if ($internalType === 'file_reference') {
-                    $config['uploadfolder'] = '';
+                    $result['processedTca']['columns'][$fieldName]['config']['uploadfolder'] = '';
                 }
 
                 // Simple list of files
index 9b70b9b..3a9c6e8 100644 (file)
@@ -97,6 +97,42 @@ class TcaGroupTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
+    public function addDataSetsUploadFolderForFileReference()
+    {
+        $input = [
+            'databaseRow' => [
+                'aField' => '',
+            ],
+            'processedTca' => [
+                'columns' => [
+                    'aField' => [
+                        'config' => [
+                            'type' => 'group',
+                            'internal_type' => 'file_reference',
+                            'maxitems' => 99999,
+                        ],
+                    ],
+                ],
+            ],
+        ];
+
+        $expected = $input;
+        $expected['databaseRow']['aField'] = [];
+        $expected['processedTca']['columns']['aField']['config']['allowed'] = '*';
+        $expected['processedTca']['columns']['aField']['config']['clipboardElements'] = [];
+        $expected['processedTca']['columns']['aField']['config']['uploadfolder'] = '';
+
+        $clipboardProphecy = $this->prophesize(Clipboard::class);
+        GeneralUtility::addInstance(Clipboard::class, $clipboardProphecy->reveal());
+        $clipboardProphecy->initializeClipboard()->shouldBeCalled();
+        $clipboardProphecy->elFromTable('_FILE')->shouldBeCalled()->willReturn([]);
+
+        $this->assertEquals($expected, $this->subject->addData($input));
+    }
+
+    /**
+     * @test
+     */
     public function addDataSetsFileData()
     {
         $input = [
index 4892ad4..1254355 100644 (file)
@@ -2121,7 +2121,7 @@ class DataHandler
             if (!$this->bypassFileHandling) {
                 // For logging..
                 $propArr = $this->getRecordProperties($table, $id);
-                // Get destrination path:
+                // Get destination path:
                 $dest = PATH_site . $tcaFieldConf['uploadfolder'];
                 // If we are updating:
                 if ($status === 'update') {