Repository navigation
fix: move_uploaded_file() and is_uploaded_file() accept a worker's uploads - #65
Merged
Merged
Conversation
…loads PHP consults SG(rfc1867_uploaded_files), which only its own multipart parser fills. A worker's files never go through that parser, so both functions refused every one of them: a worker script written for PHP-FPM could not move an upload, and the Laravel worker built its files in test mode to get round it. The shim fills the table with the request's intact files before the handler runs, as main/rfc1867.c does (path as key and value, released by the table), and destroys it when the handler returns, so a file from an earlier request, or any other file, is still refused. Deleting the files stays with Askr's guard. examples/laravel-worker.php builds ordinary UploadedFiles: isValid() checks they are uploads, ->move() is move_uploaded_file(). - e2e a_worker_can_move_its_own_uploads_and_nothing_else: the request's files are uploads and move; a moved one, the previous request's file and an arbitrary file are not. Fails without the fill (moved=0) and without the clear (previous uploaded=1). - php-src: empty_upload, max_file_size, max_file_uploads_empty_files and post_max_filesize now pass in worker mode and leave the catalogue (8 divergences remain). - laravel-smoke: an upload is valid and ->move()s; fails with the new worker on the old shim. Laravel 12 and a fresh 13.
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.
The problem
is_uploaded_file()andmove_uploaded_file()consultSG(rfc1867_uploaded_files), a table that only PHP's own multipart parser fills. A worker's files never go through that parser, so both functions refused every upload in worker mode:laravel-worker.phpbuilt its files in test mode to get round it.The fix
error == 0) right before the handler runs. It does this the same waymain/rfc1867.cdoes: the path is both key and value, and the table releases it.move_uploaded_file()from moving arbitrary files, so it must hold exactly this request's files.laravel-worker.phpbuilds ordinaryUploadedFileobjects:isValid()checks they are uploads, and->move()ismove_uploaded_file(), as under PHP-FPM.Verification
e2e
a_worker_can_move_its_own_uploads_and_nothing_else:__FILE__) is neither "uploaded" nor moved.It fails without the fill (
moved=0) and without the clear (previous uploaded=1).php-src:
empty_upload,max_file_size,max_file_uploads_empty_filesandpost_max_filesizenow pass in worker mode and have left the catalogue. 8 divergences remain.Laravel smoke: an upload is valid and
->move()s. It fails with the new worker on the old shim. Passes on Laravel 12 and a fresh 13.Note for the release: the new
laravel-worker.phpneeds Askr ≥ 1.9.2. Without the table,isValid()is false. The image and tarball ship worker and binary together, but someone who copied the worker into their app must upgrade Askr first. That goes in UPGRADING.