From 4cd338313b5bc78baba425748239a10b50624cf3 Mon Sep 17 00:00:00 2001 From: Franciszek Wawrzak Date: Fri, 6 Oct 2017 10:37:12 +0200 Subject: [PATCH 1/2] fix adminhtml file attribute edit form fixes #11252 not sure why this line was introduced as the only place this function is used seems to be here: https://github.com/magento/magento2/blob/55e9a5cc9d88ef785f39217e96da02b1cdf3e247/app/code/Magento/Customer/Model/FileUploader.php#L110 and it uses 'path' key right after call. --- app/code/Magento/Customer/Model/FileProcessor.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Customer/Model/FileProcessor.php b/app/code/Magento/Customer/Model/FileProcessor.php index 2d6917efdaf56..d482d00748324 100644 --- a/app/code/Magento/Customer/Model/FileProcessor.php +++ b/app/code/Magento/Customer/Model/FileProcessor.php @@ -181,7 +181,6 @@ public function saveTemporaryFile($fileId) ); $result = $uploader->save($path); - unset($result['path']); if (!$result) { throw new \Magento\Framework\Exception\LocalizedException( __('File can not be saved to the destination folder.') From f63d74c5674ecb4ff811c0d8ea640d6b024d758b Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Tue, 12 Dec 2017 16:01:07 +0200 Subject: [PATCH 2/2] magento/magento2#11252: fix adminhtml file attribute edit form --- app/code/Magento/Customer/Model/FileProcessor.php | 1 + app/code/Magento/Customer/Model/FileUploader.php | 2 +- app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Model/FileProcessor.php b/app/code/Magento/Customer/Model/FileProcessor.php index d482d00748324..2d6917efdaf56 100644 --- a/app/code/Magento/Customer/Model/FileProcessor.php +++ b/app/code/Magento/Customer/Model/FileProcessor.php @@ -181,6 +181,7 @@ public function saveTemporaryFile($fileId) ); $result = $uploader->save($path); + unset($result['path']); if (!$result) { throw new \Magento\Framework\Exception\LocalizedException( __('File can not be saved to the destination folder.') diff --git a/app/code/Magento/Customer/Model/FileUploader.php b/app/code/Magento/Customer/Model/FileUploader.php index b94eff6bdff44..c425ac06666c5 100644 --- a/app/code/Magento/Customer/Model/FileUploader.php +++ b/app/code/Magento/Customer/Model/FileUploader.php @@ -110,7 +110,7 @@ public function upload() $result = $fileProcessor->saveTemporaryFile($this->scope . '[' . $this->getAttributeCode() . ']'); // Update tmp_name param. Required for attribute validation! - $result['tmp_name'] = $result['path'] . '/' . ltrim($result['file'], '/'); + $result['tmp_name'] = ltrim($result['file'], '/'); $result['url'] = $fileProcessor->getViewUrl( FileProcessor::TMP_DIR . '/' . ltrim($result['name'], '/'), diff --git a/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php b/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php index f2489c8626a4f..82e1c31b54b92 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/FileUploaderTest.php @@ -140,7 +140,7 @@ public function testUpload() 'name' => $resultFileName, 'file' => $resultFileName, 'path' => $resultFilePath, - 'tmp_name' => $resultFilePath . $resultFileName, + 'tmp_name' => ltrim($resultFileName, '/'), 'url' => $resultFileUrl, ];