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

fix for FilesSize validator usage with Input #6731

Closed
wants to merge 5 commits into from
Closed

fix for FilesSize validator usage with Input #6731

wants to merge 5 commits into from

Conversation

bgotink
Copy link
Contributor

@bgotink bgotink commented Oct 3, 2014

There's a problem with FilesSize when used as validator for a FileInput: the validator doesn't accept input in the $_FILES format. It expects a filename or an array of filenames.

This PR adds support for the $_FILES format to the FilesSize validator.

@bgotink bgotink mentioned this pull request Oct 3, 2014
29 tasks
@@ -96,6 +98,16 @@ public function isValid($value, $file = null)
$size = $this->getSize();
foreach ($value as $files) {
// Is file readable ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move "Is file readable" comment on after your code addition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@samsonasik
Copy link
Contributor

need test

@bgotink
Copy link
Contributor Author

bgotink commented Oct 6, 2014

I've added a test.

@bgotink
Copy link
Contributor Author

bgotink commented Oct 7, 2014

Apparently one of the Cache test fails on PHP 5.5. I don't see any direct links with the changed code though…

}

$min = $this->getMin(true);
$max = $this->getMax(true);
$size = $this->getSize();
foreach ($value as $files) {
if (is_array($files)) {
if (!isset($files['tmp_name']) || !isset($files['name'])) {
throw new Exception\InvalidArgumentException(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This particular path seems to be uncovered by the test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not any more, as of afbfac7

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Ocramius Ocramius self-assigned this Dec 24, 2014
@Ocramius Ocramius added this to the 2.4.0 milestone Dec 24, 2014
weierophinney added a commit that referenced this pull request Feb 23, 2015
fix for FilesSize validator usage with Input
weierophinney added a commit that referenced this pull request Feb 23, 2015
@weierophinney
Copy link
Member

Merged to develop for release with 2.4.

weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
…filefilessize

fix for FilesSize validator usage with Input
weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants