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

Commit

Permalink
Merge branch 'hotfix/175'
Browse files Browse the repository at this point in the history
Close #175
  • Loading branch information
weierophinney committed Jan 7, 2019
2 parents a17e72e + 1f6725b commit 3dc2ff5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

All notable changes to this project will be documented in this file, in reverse chronological order by release.

## 2.9.1 - TBD
## 2.9.1 - 2019-01-07

### Added

Expand All @@ -22,14 +22,18 @@ 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 the default
validator of a `FileInput`. 2.9.0 changed the default to use the
fully-qualified class name of `Zend\Validator\File\Upload` as the service,
instead of the previous 'fileuploadfile`; this release returns to the original
behavior.

## 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 [];
}
}

0 comments on commit 3dc2ff5

Please sign in to comment.