After add or update the block (view listing, in particular) in a layout override getting such messages in the dblog:

Notice: Undefined index: class in layout_builder_modal_link_alter() (line 57 of /var/www/web/modules/contrib/layout_builder_modal/layout_builder_modal.module)
#0 /var/www/web/core/includes/bootstrap.inc(600): _drupal_error_handler_real(8, 'Undefined index...', '/var/www/web/mo...', 57, Array)
#1 /var/www/web/modules/contrib/layout_builder_modal/layout_builder_modal.module(57): _drupal_error_handler(8, 'Undefined index...', '/var/www/web/mo...', 57, Array)
.....
Warning: in_array() expects parameter 2 to be array, null given in layout_builder_modal_link_alter() (line 57 of /var/www/web/modules/contrib/layout_builder_modal/layout_builder_modal.module)
#0 /var/www/web/core/includes/bootstrap.inc(600): _drupal_error_handler_real(2, 'in_array() expe...', '/var/www/web/mo...', 57, Array)
#1 [internal function]: _drupal_error_handler(2, 'in_array() expe...', '/var/www/web/mo...', 57, Array)

The problem is that there are not enough checks in the above hook implementation.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Comments

    NightHunterSV created an issue. See original summary.

    NightHunterSV’s picture

    NightHunterSV’s picture

    Assigned: NightHunterSV » Unassigned
    Status: Active » Needs review
    mark_fullmer’s picture

    StatusFileSize
    new607 bytes

    The proposed array element check seems perfectly reasonable, given that the array element *must* be present (and must include use-ajax) for the modal behavior to proceed.

    I'm curious, however, which links in the settings tray are triggering this behavior. This would be good to document inline.

    Attached is a patch with the same check, but applies cleanly.

    johnwebdev’s picture

    When would the class key not be an array though?

    jeff cardwell’s picture

    Assigned: Unassigned » jeff cardwell
    jeff cardwell’s picture

    The combination of the two messages above results from the class not being set at all, rather than the class key being set to something other than an array. I haven't been able to recreate that condition "naturally", but unsetting it in the hook (unset($variables['options']['attributes']['class']);) right before line 57 will cause that combination of messages.

    If the class key is set to something other than an array, we do not see the "Notice: Undefined index" and only observe the "Warning: in_array() expects parameter 2 to be array, null given" message.

    jeff cardwell’s picture

    Status: Needs review » Reviewed & tested by the community
    jeff cardwell’s picture

    Assigned: jeff cardwell » Unassigned
    malik.kotob’s picture

    I just came across this issue when adding a views exposed filters block to a layout. The patch in #4 also worked well for me!

    johnzzon’s picture

    I'm not able to reproduce the errors. I tried exposed filters as well.
    Anyone got steps to reproduce?

    loon’s picture

    +1 RTC, the patch #4 fixed the issue.