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.
Comments
Comment #2
NightHunterSV commentedComment #3
NightHunterSV commentedComment #4
mark_fullmerThe 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.
Comment #5
johnwebdev commentedWhen would the class key not be an array though?
Comment #6
jeff cardwell commentedComment #7
jeff cardwell commentedThe combination of the two messages above results from the
classnot being set at all, rather than theclasskey 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
classkey 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.Comment #8
jeff cardwell commentedComment #9
jeff cardwell commentedComment #10
malik.kotob commentedI just came across this issue when adding a views exposed filters block to a layout. The patch in #4 also worked well for me!
Comment #11
johnzzonI'm not able to reproduce the errors. I tried exposed filters as well.
Anyone got steps to reproduce?
Comment #12
loon commented+1 RTC, the patch #4 fixed the issue.