Undefined array key interfering with other modules.

Created on 12 June 2023, over 1 year ago
Updated 10 September 2024, 2 months ago

Problem/Motivation

I recently installed the Acquia DAM module, since we have an integration with that system we want to include in our sites.

There is an AJAX error that is occurring whenever the "Add Media" button on a Media field is pressed.

An AJAX HTTP error occurred.\nHTTP Result Code: 200\nDebugging information follows.\nPath: /node/add/article?ajax_form=1&_wrapper_format=drupal_ajax&media_library_opener_id=media_library.opener.field_widget&media_library_allowed_types%5Bacquia_dam_image_asset%5D=acquia_dam_image_asset&media_library_allowed_types%5Bimage%5D=image&media_library_selected_type=acquia_dam_image_asset&media_library_remaining=1&media_library_opener_parameters%5Bfield_widget_id%5D=field_hero__image_contextual%3A-field_hero-0-subform-field_hero__panels-0-subform&media_library_opener_parameters%5Bentity_type_id%5D=paragraph&media_library_opener_parameters%5Bbundle%5D=hero_image&media_library_opener_parameters%5Bfield_name%5D=field_hero__image_contextual&hash=0n7alT78MpFJXnhSIS2_bXWs4cqnll4zu91q4Y6D6eY\nStatusText: parsererror\nResponseText: Warning: Undefined array key \"replace_checkbox_by_order_indicator\" in /app/web/modules/contrib/media_library_media_modify/src/Plugin/Field/FieldWidget/MediaLibraryWithOverrideWidget.php on line 256\n[{\"command\":\"settings\",\"settings\":{\"ajaxPageState\":{\"theme\":\"cmu_gin\",\"theme_token\":\"Nhpc2jUFucrhBInRY53uWnykjiXPtEm8zMVcWmpoqrg\",\"libraries\":\"acquia_dam\\/acquia_dam.authorization,acquia_dam\\/acquia_dam.expired_assets,acquia_dam\\/acquia_dam.media_library.reset_filter,acquia_dam\\/acquia_dam.media_library.source_menu,acquia_dam\\/media_library.style,admin_toolbar\\/toolbar.tree,admin_toolbar\\/toolbar.tree.hoverintent,admin_toolbar_search\\/search,admin_toolbar_tools\\/toolbar.icon,anchor_link\\/drupal.anchor_link,claro\\/global-styling,claro\\/node-form,cmu_datalayer\\/events,cmu_gin\\/global-ux,contextual\\/drupal.contextual-links,contextual\\/drupal.contextual-toolbar,core\\/drupal.active-link,core\\/drupal.autocomplete,core\\/drupal.collapse,core\\/drupal.date,core\\/drupal.entity-form,core\\/drupal.form,core\\/drupal.message,core\\/drupal.states,core\\/drupal.tabledrag,core\\/drupal.tableresponsive,core\\/internal.jquery.form,core\\/normalize,dashboards\\/core,datalayer\\/behaviors,devel\\/devel-toolbar,entity_browser\\/entity_reference,entity_browser\\/modal,field_group\\/core,field_group\\/formatter.details,gin\\/edit_form,gin\\/gin,gin\\/gin_accent,gin\\/gin_base,gin\\/gin_init,gin\\/gin_toolbar,gin\\/sidebar,gin\\/sticky,lightning_scheduler\\/widget,media_library\\/widget,media_library_media_modify\\/order_indicator,menu_ui\\/drupal.menu_ui,node\\/drupal.node,node\\/form,node_edit_protection\\/node_edit_protection,obfuscate_email\\/default,paragraphs\\/drupal.paragraphs.actions,paragraphs\\/drupal.paragraphs.admin,paragraphs\\/drupal.paragraphs.widget,path\\/drupal.path,pathauto\\/widget,select2\\/select2,select2\\/select2.i18n.en,system\\/admin,system\\/base,toolbar\\/toolbar,toolbar\\/toolbar.escapeAdmin,user\\/drupal.user.icons\"},\"media_library\":{\"selection_remaining\":1,\"core\":\"\\/media-library?source=core\\u0026media_library_opener_id=media_library.opener.field_widget\\u0026media_library_allowed_types%5B0%5D=acquia_dam_image_asset\\u0026media_library_selected_type=acquia_dam_image_asset\\u0026media_library_remaining=1\\u0026media_library_opener_parameters%5Bfield_widget_id%5D=field_hero__image_contextual%3A-field_hero-0-subform-field_hero__panels-0-subform\\u0026media_library_opener_parameters%5Bentity_type_id%5D=paragraph\\u0026media_library_opener_parameters%5Bbundle%5D=hero_image\\u0026media_library_opener_parameters%5Bfield_name%5D=field_hero__image_contextual\\u0026media_library_opener_parameters%5Breplace_checkbox_by_order_indicator%5D=0\\u0026media_library_opener_parameters%5Bmulti_edit_on_create%5D=0\\u0026media_library_opener_parameters%5Bno_edit_on_create%5D=0\\u0026media_library_opener_parameters%5Bcheck_selected%5D=0\\u0026hash=3p6AIxZshVuS0adanHAF0v44x2bqkJdeYkI8nM9H8hs\\u0026complete_allowed_list%5Bacquia_dam_image_asset%5D=acquia_dam_image_asset\\u0026complete_allowed_list%5Bimage%5D=image\",\"acquia_dam\":\"\\/media-library?source=acquia_dam\\u0026media_library_opener_id=media_library.opener.field_widget\\u0026media_library_allowed_types%5B0%5D=acquia_dam_image_asset\\u0026media_library_selected_type=acquia_dam_image_asset\\u0026media_library_remaining=1\\u0026media_library_opener_parameters%5Bfield_widget_id%5D=field_hero__image_contextual%3A-field_hero-0-subform-field_hero__panels-0-subform\\u0026media_library_opener_parameters%5Bentity_type_id%5D=paragraph\\u0026media_library_opener_parameters%5Bbundle%5D=hero_image\\u0026media_library_opener_parameters%5Bfield_name%5D=field_hero__image_contextual\\u0026media_library_opener_parameters%5Breplace_checkbox_by_order_indicator%5D=0\\u0026media_library_opener_parameters%5Bmulti_edit_on_create%5D=0\\u0026media_library_opener_parameters%5Bno_edit_on_create%5D=0\\u0026media_library_opener_parameters%5Bcheck_selected%5D=0\\u0026hash=3p6AIxZshVuS0adanHAF0v44x2bqkJdeYkI8nM9H8hs\\u0026complete_allowed_list%5Bacquia_dam_image_asset%5D=acquia_dam_image_asset\\u0026complete_allowed_list%5Bimage%5D=image\"},\"media_library_media_modify\":{\"replace_checkbox_by_order_indicator\":false},\"pluralDelimiter\":\"\\u0003\",\"user\":{\"uid\":\"42\",\"permissionsHash\":\"e3529c8232505b2a9aa72c81295eafd6dd1c35c17eea35bd3583cd832cd41b93\"}},\"merge\":true},{\"command\":\"add_css\",\"data\":\"\\u003Clink rel=\\u0022stylesheet\\u0022 media=\\u0022all\\u0022 href=\\u0022\\/modules\\/contrib\\/media_library_media_modify\\/css\\/order_indicator.css?rw02ls\\u0022 \\/\\u003E\\n\\u003Clink rel=\\u0022stylesheet\\u0022 media=\\u0022all\\u0022 href=\\u0022\\/modules\\/contrib\\/acquia_dam\\/css\\/media-library.css?rw02ls\\u0022 \\/\\u003E\\n\\u003Clink rel=\\u0022stylesheet\\u0022 media=\\u0022all\\u0022 href=\\u0022\\/core\\/themes\\/claro\\/css\\/components\\/media-library.ui.css?rw02ls\\u0022 \\/\\u003E\\n\\u003Clink rel=\\u0022stylesheet\\u0022 media=\\u0022all\\u0022 href=\\u0022\\/core\\/themes\\/claro\\/css\\/theme\\/media-library.css?rw02ls\\u0022 \\/\\u003E\\n\\u003Clink rel=\\u0022stylesheet\\u0022 media=\\u0022all\\u0022 href=\\u0022\\/themes\\/contrib\\/gin\\/dist\\/css\\/components\\/media_library.css?rw02ls\\u0022 \\/\\u003E\\n\"},{\"command\":\"add_js\",\"selector\":\"body\",\"data\":[{\"src\":\"\\/core\\/themes\\/claro\\/js\\/media-library.ui.js?v=9.5.8\"},{\"src\":\"\\/core\\/misc\\/checkbox.js?v=9.5.8\"},{\"src\":\"\\/core\\/themes\\/claro\\/js\\/checkbox.js?v=9.5.8\"},{\"src\":\"\\/core\\/modules\\/media_library\\/js\\/media_library.click_to_select.js?v=9.5.8\"},{\"src\":\"\\/themes\\/contrib\\/gin\\/js\\/overrides\\/media_library.view.js?v=9.5.8\"},{\"src\":\"\\/core\\/modules\\/media_library\\/js\\/media_library.ui.js?v=9.5.8\"},{\"src\":\"\\/modules\\/contrib\\/acquia_dam\\/js\\/acquia_dam.media_library.source_menu.js?rw02ls\"},{\"src\":\"\\/modules\\/contrib\\/acquia_dam\\/js\\/acquia-dam-authorization.js?rw02ls\"},{\"src\":\"\\/modules\\/contrib\\/acquia_dam\\/js\\/acquia_dam.media_library.reset_filter.js?rw02ls\"},{\"src\":\"\\/modules\\/contrib\\/media_library_media_modify\\/js\\/order_indicator.js?rw02ls\"}]},{\"command\":\"update_build_id\",\"old\":\"form-SsKhrloPiPeD8Wi2B4kAewWqH6K_nQIEJ7ST4uPKdrs\",\"new\":\"form-unYcxH_O2f2fiBiK5d720Dhk7bXUCDQF8c5AjCVqiG8\"},{\"command\":\"openDialog\",\"selector\":\"#drupal-modal\",\"settings\":null,\"data\":\"\\n\\n\\u003C!-- THEME DEBUG --\\u003E\\n\\u003C!-- THEME HOOK: \\u0027media_library_wrapper\\u0027 --\\u003E\\n\\u003C!-- BEGIN OUTPUT from \\u0027core\\/themes\\/claro\\/templates\\/classy\\/media-library\\/media-library-wrapper.html.twig\\u0027 --\\u003E\\n\\u003Cdiv id=\\u0022media-library-wrapper\\u0022 class=\\u0022acquia-dam-media-library media-library-wrapper\\u0022\\u003E\\n  \\n\\n\\u003C!-- THEME DEBUG --\\u003E\\n\\u003C!-- THEME HOOK: \\u0027container\\u0027 --\\u003E\\n\\u003C!-- BEGIN OUTPUT from \\u0027core\\/modules\\/system\\/templates\\/container.html.twig\\u0027 --\\u003E\\n\\u003Cdiv id=\\u0022acquia-dam-source-menu-wrapper\\u0022\\u003E\\n\\n\\u003C!-- THEME DEBUG --\\u003E\\n\\u003C!-- THEME HOOK: \\u0027form_element\\u0027 --\\u003E\\n\\u003C!-- FILE NAME SUGGESTIONS:\\n   * form-element--select.html.twig\\n   x form-element.html.twig\\n--\\u003E\\n\\u003C!-- BEGIN OUTPUT from \\u0027themes\\/contrib\\/gin\\/templates\\/form\\/form-element.html.twig\\u0027 --\\u003E\\n\\u003Cdiv class=\\u0022js-form-item form-item js-form-type-select form-type--select js-form-item- form-item--\\u0022\\u003E\\n            \\n\\n\\u003C!-- THEME DEBUG --\\u003E\\n\\u003C!-- THEME HOOK: \\u0027form_element_label\\u0027 --\\u003E\\n\\u003C!-- BEGIN OUTPUT from \\u0027core\\/themes\\/claro\\/templates\\/form-element-label.html.twig\\u0027 --\\u003E\\n\\u003Clabel class=\\u0022form-item__label\\u0022\\u003ESelect media source\\u003C\\/label\\u003E\\n\\u003C!-- END OUTPUT from \\u0027core\\/themes\\/claro\\/templates\\/form-element-label.html.twig\\u0027 --\\u003E\\n\\n\\n              \\n\\n\\u003C!-- THEME DEBUG --\\u003E\\n\\u003C!-- THEME HOOK: \\u0027select\\u0027 --\\u003E\\n\\u003C!-- BEGIN OUTPUT from \\u0027core\\/modules\\/system\\/templates\\/select.html.twig\\u0027 --\\u003E\\n\\u003Cselect class=\\u0022js-acquia-dam-source-field form-select form-element form-element--type-select\\u0022\\u003E\\u003Coption value=\\u0022acquia_dam\\u0022 selected=\\u0022selected\\u0022\\u003EDAM\\u003C\\/option\\u003E\\u003Coption value=\\u0022core\\u0022\\u003EMedia Types\\u003C\\/option\\u003E\\u003C\\/select\\u003E\\n\\u003C!-- END OUTPUT from \\u0027core\\/modules\\/system\\/templates\\/select.html.twig\\u0027 --\\u003E\\n\\n\\n          \\u003C\\/div\\u003E\\n\\n\\u003C!-- END OUTPUT from \\u0027themes\\/contrib\\/gin\\/templates\\/form\\/form-element.html.twig\\u0027 --\\u003E\\n\\n\\u003C\\/div\\u003E\\n\\n\\u003C!-- END OUTPUT from \\u0027core\\/modules\\/system\\/templates\\/container.html.twig\\u0027 --\\u003E\\n\\n\\n  \\n\\n\\u003C!-- THEME DEBUG --\\u003E\\n\\u003C!-- THEME HOOK: \\u0027container__media_library_content\\u0027 --\\u003E\\n\\u003C!-- FILE NAME SUGGESTIONS:\\n   x container--media-library-content.html.twig\\n   x container--media-library-content.html.twig\\n   * container.html.twig\\n--\\u003E\\n\\u003C!-- BEGIN OUTPUT from \\u0027core\\/themes\\/claro\\/templates\\/classy\\/media-library\\/container--media-library-content.html.twig\\u0027 --\\u003E\\n\\u003Cdiv id=\\u0022media-library-content\\u0022 class=\\u0022media-library-content\\u0022\\u003ESite is not authenticated with Acquia DAM. Please \\u003Ca href=\\u0022https:\\/\\/cmu.widencollective.com\\/allowaccess?client_id=3b41085e6ff4d9f87307f4418bfce7ef6ed12860.app.widen.com\\u0026amp;redirect_uri=https:\\/\\/cmu.lndo.site\\/acquia-dam\\/auth\\u0022 target=\\u0022blank\\u0022\\u003Eauthenticate\\u003C\\/a\\u003E it to browse assets. Once successfully authenticated, close this modal and reopen it to browse Acquia DAM assets.\\u003C\\/div\\u003E\\n\\n\\u003C!-- END OUTPUT from \\u0027core\\/themes\\/claro\\/templates\\/classy\\/media-library\\/container--media-library-content.html.twig\\u0027 --\\u003E\\n\\n\\n\\u003C\\/div\\u003E\\n\\n\\u003C!-- END OUTPUT from \\u0027core\\/themes\\/claro\\/templates\\/classy\\/media-library\\/media-library-wrapper.html.twig\\u0027 --\\u003E\\n\\n\",\"dialogOptions\":{\"dialogClass\":\"media-library-widget-modal\",\"title\":\"Add or select media\",\"height\":\"75%\",\"width\":\"75%\",\"modal\":true}}]

The error seems related to the `$settings['replace_checkbox_by_order_indicator']` key on the $settings variable.

Steps to reproduce

This may be hard for others to reproduce since it requires access to an Acquia DAM (Digital Asset Management) system. However, it might be possible to reproduce without authenticating, as I was able to do so locally.

Regardless, the steps to reproduce are:

1. Install Media Library Media Modify module and set up a content type using the new media field provided.
2. Install Acquia DAM module.
3. Click on "Add Media" on your new field.
4. Error will be in JavaScript console.

Proposed resolution

I can provide a patch soon that does a null coalescing check where the error happens.

I would most graciously appreciate assistance with this task, as this is not only my first time contributing code to a contrib project, but my first time generating a patch. Be patient with me.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States nessthehero

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024