Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Fix regression introduced in 2.9.0 when overriding FileUpload default validator #175

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/FileInput/HttpServerFileInputDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions test/FileInput/HttpServerFileInputDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
23 changes: 23 additions & 0 deletions test/FileInput/TestAsset/FileUploadMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* @see https://github.com/zendframework/zend-inputfilter for the canonical source repository
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
* @license https://github.com/zendframework/zend-inputfilter/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\InputFilter\FileInput\TestAsset;

use Zend\Validator\ValidatorInterface;

final class FileUploadMock implements ValidatorInterface
{
public function isValid($value)
{
return true;
}

public function getMessages()
{
return [];
}
}