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

Commit 3dc2ff5

Browse files
committed
Merge branch 'hotfix/175'
Close #175
2 parents a17e72e + 1f6725b commit 3dc2ff5

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

CHANGELOG.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
## 2.9.1 - TBD
5+
## 2.9.1 - 2019-01-07
66

77
### Added
88

@@ -22,14 +22,18 @@ All notable changes to this project will be documented in this file, in reverse
2222

2323
### Fixed
2424

25-
- Nothing.
25+
- [#175](https://github.com/zendframework/zend-inputfilter/pull/175) fixes a regression introduced in 2.9.0 when overriding the default
26+
validator of a `FileInput`. 2.9.0 changed the default to use the
27+
fully-qualified class name of `Zend\Validator\File\Upload` as the service,
28+
instead of the previous 'fileuploadfile`; this release returns to the original
29+
behavior.
2630

2731
## 2.9.0 - 2018-12-17
2832

2933
### Added
3034

3135
- [#172](https://github.com/zendframework/zend-inputfilter/pull/172) adds support for PSR-7 `UploadedFileInterface` to `Zend\InputFilter\FileInput`.
32-
It adds a new interface, `Zend\InputFilter\FileInput\FileInputDecoratorInterface`,
36+
It adds a new interface, `Zend\InputFilter\FileInput\FileInputDecoratorInterface`,
3337
which defines methods required for validating and filtering file uploads. It
3438
also provides two implementations of it, one for standard SAPI file uploads,
3539
and the other for PSR-7 uploads. The `FileInput` class does detection on the

src/FileInput/HttpServerFileInputDecorator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ protected function injectUploadValidator(ValidatorChain $chain)
153153
return $chain;
154154
}
155155

156-
$chain->prependByName(UploadValidator::class, [], true);
156+
$chain->prependByName('fileuploadfile', [], true);
157157
$this->subject->autoPrependUploadValidator = false;
158158

159159
return $chain;

test/FileInput/HttpServerFileInputDecoratorTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,17 @@ public function testIsEmptyFileMultiFileOk()
272272
$this->assertFalse($this->input->isEmptyFile($rawValue));
273273
}
274274

275+
public function testDefaultInjectedUploadValidatorRespectsRelease2Convention()
276+
{
277+
$input = new FileInput('foo');
278+
$validatorChain = $input->getValidatorChain();
279+
$pluginManager = $validatorChain->getPluginManager();
280+
$pluginManager->setInvokableClass('fileuploadfile', TestAsset\FileUploadMock::class);
281+
$input->setValue('');
282+
283+
$this->assertTrue($input->isValid());
284+
}
285+
275286
/**
276287
* Specific FileInput::merge extras
277288
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-inputfilter for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
5+
* @license https://github.com/zendframework/zend-inputfilter/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\InputFilter\FileInput\TestAsset;
9+
10+
use Zend\Validator\ValidatorInterface;
11+
12+
final class FileUploadMock implements ValidatorInterface
13+
{
14+
public function isValid($value)
15+
{
16+
return true;
17+
}
18+
19+
public function getMessages()
20+
{
21+
return [];
22+
}
23+
}

0 commit comments

Comments
 (0)