Repository navigation
fix: make multipart file uploads work - #16
Merged
Merged
Conversation
Any multipart part with a filename failed: $_FILES held Symfony UploadedFile objects, which can't be serialized for the child process. The client now sends the array a web server would put in $_FILES. The CLI SAPI has no real uploads, so is_uploaded_file() and move_uploaded_file() refused every file, and frameworks reject uploads through them. The runtime now replaces both, the same way as header(), and accepts the temporary files the client wrote for this request only, so a script can't use them to move arbitrary files. The upload tests caught every exception and passed anyway. They now assert the uploaded name, type, size and contents, MIME detection, and moving the file.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16 +/- ##
============================================
+ Coverage 93.51% 93.59% +0.08%
- Complexity 575 590 +15
============================================
Files 16 17 +1
Lines 1341 1374 +33
============================================
+ Hits 1254 1286 +32
- Misses 87 88 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Any multipart part with a
filenamefailed withFailed to serialize globals data: Serialization of 'Symfony\Component\HttpFoundation\File\UploadedFile' is not allowed.$_FILESwas filled with theUploadedFileobjects from the Symfony request, and they can't be serialized for the child process. The client now sends the array a web server puts in$_FILES(name,full_path,type,tmp_name,error,size).Fixing that alone is not enough for most apps, because the CLI SAPI has no real uploads.
is_uploaded_file()returns false andmove_uploaded_file()refuses to move, and frameworks like Symfony go through them. The runtime now replaces both functions, the same way it already replacesheader()(disabled withdisable_functions, redefined infunctions.php). They only accept the temporary files the client wrote for this request, recorded before the script runs, so a script cannot usemove_uploaded_file()to move any other file.The upload tests in
ClientRequestTestcaught every exception and had their assertions behindifguards, so they passed while uploads were broken. They now assert the name, type, size and contents seen by the script, MIME detection from the contents, and moving the file. 6 of the new tests fail onmain.A part name like
files[]is still not expanded into nested arrays as PHP does for real uploads. I noted it in the README, it was already the case.