From 547ae979dd83c7fd4b13f5a2a146310337be5fb7 Mon Sep 17 00:00:00 2001 From: Sascha Egerer <sascha@sascha-egerer.de> Date: Thu, 22 Jun 2017 17:31:59 +0200 Subject: [PATCH] [BUGFIX] Initialize uploadfolder key for TCA group file_reference 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> --- .../Form/FormDataProvider/TcaGroup.php | 4 +-- .../Form/FormDataProvider/TcaGroupTest.php | 36 +++++++++++++++++++ .../core/Classes/DataHandling/DataHandler.php | 2 +- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaGroup.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaGroup.php index a1a9b858d9c4..5b60b59f5529 100644 --- a/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaGroup.php +++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaGroup.php @@ -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 diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaGroupTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaGroupTest.php index 9b70b9b47fd1..3a9c6e800f86 100644 --- a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaGroupTest.php +++ b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaGroupTest.php @@ -94,6 +94,42 @@ class TcaGroupTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase $this->subject->addData($input); } + /** + * @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 */ diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 4892ad43d838..1254355e748e 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -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') { -- GitLab