diff --git a/CHANGELOG.md b/CHANGELOG.md index 844669fb..59636b5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,14 +22,15 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- Nothing. +- [#175](https://github.com/zendframework/zend-inputfilter/pull/175) fixes a regression introduced in 2.9.0 when + overriding FileUpload default validator. ## 2.9.0 - 2018-12-17 ### Added - [#172](https://github.com/zendframework/zend-inputfilter/pull/172) adds support for PSR-7 `UploadedFileInterface` to `Zend\InputFilter\FileInput`. - It adds a new interface, `Zend\InputFilter\FileInput\FileInputDecoratorInterface`, + It adds a new interface, `Zend\InputFilter\FileInput\FileInputDecoratorInterface`, which defines methods required for validating and filtering file uploads. It also provides two implementations of it, one for standard SAPI file uploads, and the other for PSR-7 uploads. The `FileInput` class does detection on the diff --git a/src/FileInput/HttpServerFileInputDecorator.php b/src/FileInput/HttpServerFileInputDecorator.php index 0d9e0bae..0e6323b7 100644 --- a/src/FileInput/HttpServerFileInputDecorator.php +++ b/src/FileInput/HttpServerFileInputDecorator.php @@ -153,7 +153,7 @@ protected function injectUploadValidator(ValidatorChain $chain) return $chain; } - $chain->prependByName(UploadValidator::class, [], true); + $chain->prependByName('fileuploadfile', [], true); $this->subject->autoPrependUploadValidator = false; return $chain; diff --git a/test/FileInput/HttpServerFileInputDecoratorTest.php b/test/FileInput/HttpServerFileInputDecoratorTest.php index c3ba2bd0..bc935872 100644 --- a/test/FileInput/HttpServerFileInputDecoratorTest.php +++ b/test/FileInput/HttpServerFileInputDecoratorTest.php @@ -272,6 +272,17 @@ public function testIsEmptyFileMultiFileOk() $this->assertFalse($this->input->isEmptyFile($rawValue)); } + public function testDefaultInjectedUploadValidatorRespectsRelease2Convention() + { + $input = new FileInput('foo'); + $validatorChain = $input->getValidatorChain(); + $pluginManager = $validatorChain->getPluginManager(); + $pluginManager->setInvokableClass('fileuploadfile', TestAsset\FileUploadMock::class); + $input->setValue(''); + + $this->assertTrue($input->isValid()); + } + /** * Specific FileInput::merge extras */ diff --git a/test/FileInput/TestAsset/FileUploadMock.php b/test/FileInput/TestAsset/FileUploadMock.php new file mode 100644 index 00000000..a03b3387 --- /dev/null +++ b/test/FileInput/TestAsset/FileUploadMock.php @@ -0,0 +1,23 @@ +