Problem/Motivation
I can not upload any Media with the Combined Upload enabled.
Error occurs on 2.2.0-alpha-2 on Drupal 10.4.2
Error does not occur on 2.1.0-beta5 on Drupal 10.4.2
Not tested on Drupal 11 yet.
Steps to reproduce
1. In /admin/config/media/media_directories, enable 'Combined Upload'. Wether all or only some or one Media Type gets activated, does not matter.
2. Go to Media-Directory-Browser, be it via Media-Directory-Embed-Button in a Ckeditor5-editor, or via /admin/content/browser
3. Choose any Directory. Wether its Root, Root with all files shown or any subdirectory does not matter.
4. Click 'Add Media'. The Media-Upload-Modal presents.
5. In Field 'Select Fields', click Browse
6. In the file-browser, choose any number, any type of file. Tested with one and multiple images (png and jpg), with one and multiple pdfs, with one image and one pdf.
7. On clicking 'Choose' on the file-browser, an error occurs.
- The Media-Upload-Modal is still open, but below, on the /admin/content/browser-page there is a red-on-black error-message "Add-Media-Modal is still here, but in Browser-Page below, we get a red-on-black error-message 'Oops, something went wrong. Check your browser's developer console for more details'. "
- The browser's developer console says:
Object { message: "
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /en/admin/media_directories/media/add?media_type=combined_upload&target_bundles%5Baudio%5D=audio&target_bundles%5Bdocument%5D=document&target_bundles%5Bimage%5D=image&target_bundles%5Bremote_video%5D=remote_video&target_bundles%5Bvideo%5D=video&active_directory=-1&cardinality=-1&selection_mode=keep&ajax_form=1
StatusText: 500 Service unavailable (with message)
ResponseText: The website encountered an unexpected error. Try again later.TypeError: array_merge(): Argument #2 must be of type array, Symfony\Component\Validator\ConstraintViolationList given in array_merge() (line 55 of core/modules/file/src/Validation/FileValidator.php). Drupal\file\Validation\FileValidator->validate() (Line: 285)
Drupal\file\Upload\FileUploadHandler->handleFileUpload() (Line: 660)
file_save_upload() (Line: 536)
_file_save_upload_from_form() (Line: 1007)
file_managed_file_save_upload() (Line: 76)
Drupal\file\Element\ManagedFile::valueCallback()
call_user_func_array() (Line: 1264)
Drupal\Core\Form\FormBuilder->handleInputElement() (Line: 1004)
Drupal\Core\Form\FormBuilder->doBuildForm() (Line: 1074)
Drupal\Core\Form\FormBuilder->doBuildForm() (Line: 1074)
Drupal\Core\Form\FormBuilder->doBuildForm() (Line: 579)
Drupal\Core\Form\FormBuilder->processForm() (Line: 326)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 240)
media_directories_ui_preprocess_media_directories_add()
call_user_func_array() (Line: 261)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 153)
Drupal\Core\Render\Renderer->Drupal\Core\Render\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 152)
Drupal\Core\Render\Renderer->renderRoot() (Line: 36)
Drupal\Core\Ajax\OpenDialogCommand->getRenderedContent() (Line: 148)
Drupal\Core\Ajax\OpenDialogCommand->render() (Line: 43)
Drupal\Core\Ajax\AjaxResponse->addCommand() (Line: 403)
Drupal\media_directories_ui\Controller\MediaDirectoriesController->mediaAdd()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\
egotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)
", name: "AjaxError", stack: "@http://URL_REDACTED/core/misc/ajax.js?v=10.4.2:196:32
@http://OUR_URL/core/misc/ajax.js?v=10.4.2:1935:3
" }
- 'drush ws' says:
ID Date Type Severity Message
-------- -------------- ------ ---------- ----------------------------------------------------------------------------
689316 07/Feb 10:30 php Fehler TypeError: array_merge(): Argument #2 must be of type array,
Symfony\Component\Validator\ConstraintViolationList given in array_merge()
(line 55 of
PATH_REDACTED/src/drupal/cor
e/modules/file/src/Validation/FileValidator.php).
Proposed resolution
Workaround: Disable 'Combined Upload' in /admin/config/media/media_directories. Without combined upload, uploading pdfs and images works as expected.
Comments
Comment #2
mullzk commentedUpdate to Drupal 11.1.2:
Alpha2 mostly works, except uploading:
As on Drupal 10.4.2, Uploading files fails when Combined Upload is enabled. The steps to reproduction are the same, but now there is a different error-message, and it is presented in the upload-modal itself:
But on D11, the workaround no longer works: With Combined Uploads disabled, when choosing a document or image in the browser-file-manager, I get the error-message:
The "file_validate_size" plugin does not exist. Valid plugin IDs for Drupal\Core\Validation\ConstraintManager are:, followed by the same List of ClassNames.Other than that, alpha-2 works for me on Drupal 11. Aside from this bug, is there any thing we can help to bring it to stable?
Comment #3
ytsurkThank you for reporting this issue in such good detail. I'm having a look at it now.
To make it stable, or an RC, we need the following IMO
#3185648: Loading times decrease for directories containing 100+ of medias
#3383658: Images in media browser have no hover effect and selected effect in media browser
#3471815: Media library modal is shifted down when a new media is uploaded
#3444544: Support OEmbed remote url
I'll soon make a -beta version though.
Comment #4
ytsurkFixed in #3505416: Respecting file validator API
Comment #5
mullzk commentedI can confirm that alpha3 fixes my issue both on D10.4.2 and D11.1.2
Thank you very much for the fix, and your work in general