Saving a media item override for a none default language fails

Created on 17 October 2023, about 1 year ago

Problem/Motivation

For testing purposes I've set up a multilingual site. The default language is English and I've added German as the second language. Overriding english media items works without any problem. I am able to make any changes to an english media item and then press save on the override media item modal. In contrast when I try the same for a german media item on a node translated into german I am unable to close the override media item modal. On save I only see the the spinner for a second but the model isn't closing and the override value isn't actually saved (in case i click the modal's button after clicking save two or three times and then reopen the modal for the media item by clicking the pencil icon).

Steps to reproduce

  • Create a multilingual site with two languages. First language English, second language German (I've installed German as the second language and will use the German as the placeholder for the second language for the rest of the steps)
  • On /admin/config/regional/language/detection activate "Interface text language detection" and "Content language detection". For the former check "Account administration pages" and "URL" and for the latter check "Content language" and "URL".
  • On the user profile set "Site language" and "Administration pages language" to English.
  • Add contextmod field on /admin/structure/types/manage/article/fields
  • Add three plain text fields at /admin/structure/media/manage/image/fields
  • Enable the created fields on /admin/structure/media/manage/image/form-display/media_library and /admin/structure/media/manage/image/display/media_library
  • On /admin/config/regional/content-language enable the custom language settings for content and media. For content everything for the article content type including contextmod. Within media everything for the image media type including the three newly created fields.
  • Now create a node in english and create a translation for it in german as well.
  • Create two or three media items of the media type image and fill out the alt text and the three plain text fields for each of them
  • Translate the two or three media items into german as well.
  • Open the english node and add the two or three media items create in english.
  • Save the node
  • Open the node translated into german and add the two or three media items translated into german.
  • Save the german node.
  • Open the english node again and edit one of the media items and override one of the fields and save
    => the override of media item gets properly saved.
  • Open the german node again and edit one of the translated media items and override one of the fields and save.
    => The modal isn't properly closed and the media item not saved -> see no_save.mp4

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany rkoller NΓΌrnberg, Germany

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @rkoller
  • πŸ‡©πŸ‡ͺGermany rkoller NΓΌrnberg, Germany

    revisited the issue today and was unable to reproduce it for newly created nodes and their translations. the error outlined in the issue summary seems exclusive to the one translated node i first ran into the issue. but there are some warnings in the recent log messages i completely forgot to check when i wrote up the issue. on each save there are these two entries:

    location:
    https://modi.ddev.site/de/media_library_media_modify?_wrapper_format=drupal_ajax&ajax_form=1&destination=%2Fadmin%2Fcontent&hash=YRK2p-SDFvLlc-Yf-Dpx2xabT12UFryYi5UHqX-9Sx4

    Referrer
    https://modi.ddev.site/de/node/2/edit?destination=/admin/content

    Message

    Deprecated function: explode(): Passing null to parameter #2 ($string) of type string is deprecated in Drupal\file\Element\ManagedFile::uploadAjaxCallback() (line 184 of /var/www/html/web/core/modules/file/src/Element/ManagedFile.php)
    #0 /var/www/html/web/core/includes/bootstrap.inc(164): _drupal_error_handler_real(8192, 'explode(): Pass...', '/var/www/html/w...', 184)
    #1 [internal function]: _drupal_error_handler(8192, 'explode(): Pass...', '/var/www/html/w...', 184)
    #2 /var/www/html/web/core/modules/file/src/Element/ManagedFile.php(184): explode('/', NULL)
    #3 [internal function]: Drupal\file\Element\ManagedFile::uploadAjaxCallback(Array, Object(Drupal\Core\Form\FormState), Object(Symfony\Component\HttpFoundation\Request))
    #4 /var/www/html/web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php(69): call_user_func_array(Array, Array)
    #5 /var/www/html/web/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php(109): Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse(Object(Symfony\Component\HttpFoundation\Request), Array, Object(Drupal\Core\Form\FormState), Array)
    #6 [internal function]: Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber->onException(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\tracer\EventDispatcher\TraceableEventDispatcher))
    #7 /var/www/html/web/modules/contrib/tracer/src/EventDispatcher/TraceableEventDispatcher.php(93): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\tracer\EventDispatcher\TraceableEventDispatcher))
    #8 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(240): Drupal\tracer\EventDispatcher\TraceableEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...')
    #9 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(91): Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object(Drupal\Core\Form\FormAjaxException), Object(Symfony\Component\HttpFoundation\Request), 1)
    #10 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #11 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #12 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #13 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #14 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #15 /var/www/html/web/modules/contrib/tracer/src/StackMiddleware/TracesMiddleware.php(42): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #16 /var/www/html/web/modules/contrib/webprofiler/src/StackMiddleware/WebprofilerMiddleware.php(34): Drupal\tracer\StackMiddleware\TracesMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #18 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #19 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #20 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #21 {main}
    

    Location
    https://modi.ddev.site/de/media_library_media_modify?_wrapper_format=drupal_ajax&ajax_form=1&destination=%2Fadmin%2Fcontent&hash=YRK2p-SDFvLlc-Yf-Dpx2xabT12UFryYi5UHqX-9Sx4

    Referrer
    https://modi.ddev.site/de/node/2/edit?destination=/admin/content

    Message

    Warning: Undefined array key "#prefix" in Drupal\file\Element\ManagedFile::uploadAjaxCallback() (line 199 of /var/www/html/web/core/modules/file/src/Element/ManagedFile.php)
    #0 /var/www/html/web/core/includes/bootstrap.inc(164): _drupal_error_handler_real(2, 'Undefined array...', '/var/www/html/w...', 199)
    #1 /var/www/html/web/core/modules/file/src/Element/ManagedFile.php(199): _drupal_error_handler(2, 'Undefined array...', '/var/www/html/w...', 199)
    #2 [internal function]: Drupal\file\Element\ManagedFile::uploadAjaxCallback(Array, Object(Drupal\Core\Form\FormState), Object(Symfony\Component\HttpFoundation\Request))
    #3 /var/www/html/web/core/lib/Drupal/Core/Form/FormAjaxResponseBuilder.php(69): call_user_func_array(Array, Array)
    #4 /var/www/html/web/core/lib/Drupal/Core/Form/EventSubscriber/FormAjaxSubscriber.php(109): Drupal\Core\Form\FormAjaxResponseBuilder->buildResponse(Object(Symfony\Component\HttpFoundation\Request), Array, Object(Drupal\Core\Form\FormState), Array)
    #5 [internal function]: Drupal\Core\Form\EventSubscriber\FormAjaxSubscriber->onException(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\tracer\EventDispatcher\TraceableEventDispatcher))
    #6 /var/www/html/web/modules/contrib/tracer/src/EventDispatcher/TraceableEventDispatcher.php(93): call_user_func(Array, Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...', Object(Drupal\tracer\EventDispatcher\TraceableEventDispatcher))
    #7 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(240): Drupal\tracer\EventDispatcher\TraceableEventDispatcher->dispatch(Object(Symfony\Component\HttpKernel\Event\ExceptionEvent), 'kernel.exceptio...')
    #8 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(91): Symfony\Component\HttpKernel\HttpKernel->handleThrowable(Object(Drupal\Core\Form\FormAjaxException), Object(Symfony\Component\HttpFoundation\Request), 1)
    #9 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #10 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #11 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #12 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #13 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #14 /var/www/html/web/modules/contrib/tracer/src/StackMiddleware/TracesMiddleware.php(42): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #15 /var/www/html/web/modules/contrib/webprofiler/src/StackMiddleware/WebprofilerMiddleware.php(34): Drupal\tracer\StackMiddleware\TracesMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #16 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\webprofiler\StackMiddleware\WebprofilerMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #18 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #19 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #20 {main}
    

    And i forgot to mention the setup. It is Drupal 10.1.5 with PHP 8.2.11 and MariaDB 10.5.22 on DDEV

  • πŸ‡ΊπŸ‡¦Ukraine ankondrat4 Lutsk

    Hello.
    This issue related to module file of Drupal core core/modules/file/src/Element/ManagedFile.php

  • πŸ‡ΊπŸ‡¦Ukraine ankondrat4 Lutsk
  • πŸ‡ΊπŸ‡¦Ukraine ankondrat4 Lutsk

    ankondrat4 β†’ changed the visibility of the branch 3394728-saving-a-media to hidden.

  • Pipeline finished with Failed
    29 days ago
    Total: 552s
    #319066
  • Pipeline finished with Success
    29 days ago
    Total: 3329s
    #319076
  • πŸ‡ΊπŸ‡¦Ukraine ankondrat4 Lutsk

    Created MR. Please review changes)

  • πŸ‡ΊπŸ‡¦Ukraine ankondrat4 Lutsk
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Issue summary appears incomplete. With these kind of issues putting just an empty check usually isn't correct. Need to do some backtracing and figure out why it's undefined so we aren't masking a larger issue.

Production build 0.71.5 2024