Uninstalling Media Gallery doesn't remove media_colorbox entries

Created on 30 December 2023, 12 months ago
Updated 26 February 2024, 10 months ago

Problem/Motivation

Uninstalling Media Gallery doesn't remove media_colorbox entries in media display. If media_colorbox has been used somewhere before uninstall in any display settings, this may lead to white screen and generate errors like

Undefined array key "media_colorbox" in Drupal\field_ui\Form\EntityDisplayFormBase->saveDisplayStatuses() (line 881 of /path_to_site/web/core/modules/field_ui/src/Form/EntityDisplayFormBase.php).

and

Call to a member function getConfigDependencyName() on null in Drupal\Core\Entity\EntityDisplayBase->calculateDependencies() (line 300 of /path_to_site/web/core/lib/Drupal/Core/Entity/EntityDisplayBase.php).

or

Cannot access offset of type string on string in Drupal\media\Plugin\Field\FieldFormatter\OEmbedFormatter->settingsSummary() (line 324 of /path_to_site/web/core/modules/media/src/Plugin/Field/FieldFormatter/OEmbedFormatter.php).

when accessing the media display modes concernend or when enabling/disabling those modes.

Steps to reproduce

  1. Install media_gallery with its colorbox dependency if not already installed
  2. Go to admin/structure/media/manage/remote_video/display
  3. At the bottom of the page activate the media_colorbox mode and save
  4. Go to your database and serach for media_colorbox_entries
  5. SELECT * FROM `drp_config` WHERE `name` LIKE '%media_colorbox%'
  6. You should see something like this:
  7. core.entity_view_display.media.image.media_colorbox
  8. core.entity_view_mode.media.media_colorbox
  9. core.entity_view_mode.media.media_colorbox (lang:en in case multilang site)
  10. and core.entity_view_display.media.remote_video.media_colorbox (this is the media type where it was activated)
  11. Check database as in 5
  12. You still have "core.entity_view_display.media.remote_video.media_colorbox"

  13. Note: desactivating media_colorbox in remote_video display before uninstalling doesn't change anything, the entry remains in the database

Proposed resolution

If you run in a white screen:
Uninstall the media_gallery - Delete the entries in the database if you run in a white screen - Reinstall
Of course this is not a solution and should be avoided unless you are in a deadlock.

Can this be a beginning of solution:
modify accordingly core.entity_view_display.media.image.media_colorbox.yml to include the other standard/default media types

dependencies:
  config:
    - core.entity_view_mode.media.media_colorbox
    - <strong>field.field.media.image.field_media_image</strong>
    - image.style.media_gallery_image
    - media.type.image
  module:
    - colorbox
_core:
  default_config_hash: jOwnt_yq6AKAfqU6f0xKnxEkFQ2eTPJWxrk3WMLbL68
id: <strong>media.image.media_colorbox</strong>

But how to manage it if an user creates extra media types ?

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

2.2

Component

Code

Created by

🇫🇷France erwangel

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

Comments & Activities

Production build 0.71.5 2024