-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a validation issue on multiple file upload #2265
Conversation
This looks like a nice expansion on uploads. One of the admins should look over it as well but in the meantime it will definitely need some tests and updates to the User Guide:
If you want help editing or reviewing those I would be glad to assist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm like this addition. I had one comment where I think you'll hit an exception if multiple files exist.
Definitely need tests and docs updates as @MGatner said.
|
||
if ($this->hasFile($name)) | ||
{ | ||
if (strpos($name, '.') !== false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure this needs an is_string()
check before. An array would throw an exception under strpos
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesnt need is_string() because $name is a string not an arrary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doh! You're correct. Sorry, confused it when I saw the is_array
check below. My bad for scanning too quickly.
@MGatner it will be awesome if you could help with the editing/reviewing of the User Guide. I will try to write some tests to validate the changes. |
By the way, I need some help with the following: I installed PHPUnit to be able to create and run the tests and detected that there are errors with the setUp() and tearDown() function definition. They should be as defined in the class TestCase:setUp():void / TestCase:tearDown():void. I think there must have been an update in the TestCase class from PHPUnit where the return type was explicity declared as :void. I've already updated all classes that override these functions and added the return type: void to them. Now my question is whether I should commit these changes to your framework or should I keep them local? |
I remember seeing that error previously, but I believe it had to do with the version of PHPUnit that was being used. It's been a while, though. For now - keep those locally. Do you use a global PHPUnit install? If you use composer to install the dev dependencies locally it will provide the version that the framework is tested with in the |
I'm not using a global installation. I did the installation with the composer but it must have gone wrong so I will have to see later then. I will leave it locally and then see what happened and if i've installed a wrong version of PHPUnit. Thanks |
…>...():void" This reverts commit 9ce0d88.
I've just added now 5 tests to check getFileMultiple(). If you can see if its necessary more tests or even if this ones are ok, i'll apreciate. |
I’m okay with this merge but let’s be sure the User Guide gets an update at some point. |
Agreed. There are a couple of user guide updates in the works as housekeepig prep for rc.2 :) |
Fix a validation issue on multiple file upload mentionate in #2175
A function has been created in FileCollection where it will return null if it does not find the uploaded file or else return an array of multiple uploaded files so that a multiple upload can be validated.
Then the validation rules were changed so that it was checked first if the upload had been set with multiple files and if it was then validate all uploaded files returning error if any of them did not verify the rule.
Checklist: