-
Notifications
You must be signed in to change notification settings - Fork 152
File validation fails when file contains sub-arrays #57
Conversation
Please update the pull request summary to describe what this accomplishes; since I link to the PRs in the changelog, that's often the first place people look to understand how the change impacts them. To be clear: we already support sub-arrays, but specifically indexed sub-arrays, vs associative sub-arrays, which is what this PR addresses. |
@@ -469,6 +469,7 @@ private static function createUploadedFileFromSpec(array $value) | |||
*/ | |||
private static function normalizeNestedFileSpec(array $files = []) | |||
{ | |||
$normalizedFiles = []; |
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.
There's no need to create a new array here.
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 stand corrected when running the unit tests. Still trying to understand why this change results in any change in behavior…
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.
The UploadedFile
objects were being appended to the $files
array, which meant that the tmp_name
and other attributes preceeded them in the array. When same array gets passed to the validation function, it was trying to then validate strings such as the tmp_name
as an instance of UploadedFile
, and failing. So I just created a new array to store the UploadedFile
objects in and returned that instead.
File validation fails when file contains sub-arrays
- Already have tests for nested arrays; this one is specifically for associative arrays.
I've updated the summary for you. |
Thank you. |
This patch updates the
ServerRequestFactory
to properly marshal uploaded files that are represented as a nested associative array (i.e., sub-arrays with non-numeric keys). As an example, prior to this patch, the following uploaded file structure would fail:This structure is now correctly parsed.