diff --git a/CHANGELOG.md b/CHANGELOG.md index 203ec375..ab741f76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- Nothing. +- [#78](https://github.com/zendframework/zend-filter/pull/78) Fix rename upload when target is not specified. ## 2.9.0 - 2018-12-12 diff --git a/src/File/RenameUpload.php b/src/File/RenameUpload.php index 615bd480..117b07cf 100644 --- a/src/File/RenameUpload.php +++ b/src/File/RenameUpload.php @@ -373,7 +373,7 @@ private function filterSapiUploadedFile(array $fileData) $targetFile = $this->getFinalTarget($sourceFile, $clientFilename); if ($sourceFile === $targetFile || ! file_exists($sourceFile)) { - return $value; + return $fileData; } $this->checkFileExists($targetFile); diff --git a/test/File/RenameUploadTest.php b/test/File/RenameUploadTest.php index bf462611..22c75b25 100644 --- a/test/File/RenameUploadTest.php +++ b/test/File/RenameUploadTest.php @@ -412,4 +412,23 @@ public function testReturnUnfiltered($input) $this->assertEquals($input, $filter($input)); } + + /** + * @return void + */ + public function testTargetSameAsSource() + { + $filter = new RenameUploadMock(); + + $this->assertEquals( + [ + 'tmp_name' => $this->sourceFile, + 'name' => $this->targetFile, + ], + $filter([ + 'tmp_name' => $this->sourceFile, + 'name' => $this->targetFile, + ]) + ); + } }