Repository navigation
refactor!: pass the file to MediaHandler as a Symfony File - #6783
Merged
Merged
Conversation
`MediaHandler::add()`/`edit()` took the file in the `$_FILES` shape (`name`, `tmp_name`/`path`, `error`). Now
`$data['file']` is a Symfony `File`, an `UploadedFile` for uploads, e.g. `Core::getRequest()->files->get('file')`.
The upload errors are still handled by the handler, and `isValid()` additionally ensures that an `UploadedFile` really
was uploaded via http. The `isUpload` flag of `MediaAdding` is derived from the class.
The signatures follow the other handlers: `$meta` comes right after `$data`, the options after it, and `edit()` takes
the language as required second parameter:
MediaHandler::add($data, $doSubindexing, $types, $meta) -> add($data, $meta, $subindexing, $types)
MediaHandler::edit($filename, $data, $languageId, $meta) -> edit($filename, $languageId, $data, $meta)
In `edit()` missing keys keep their value, `category_id` and `title` are no longer required. In `add()` `title` is
optional.
gharlan
force-pushed
the
media-handler-file
branch
from
October 21, 2026 19:33
2b2bcc5 to
c4e5fd3
Compare
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.
MediaHandler::add()/edit()took the file in the$_FILESshape (name,tmp_name/path,error). Now$data['file']is a SymfonyFile(symfony/http-foundationis already a dependency):UploadedFile::isValid()additionally ensures the file really was uploaded via http (is_uploaded_file()); previously "is an upload" only depended ontmp_namebeing set.MediaAdding::$isUploadis derived frominstanceof UploadedFile.Breaking changes
Signatures aligned with the other handlers (
$metaright after$data, options after it, the language as required second parameter ofedit()):$data['file']is aSymfony\Component\HttpFoundation\File\Fileinstead of an arrayedit(): missing keys keep their value,category_idandtitleare no longer required;filereplaces the fileadd():titleis optionalTested in the backend: upload, edit with and without replacing the file, sync.