Problem/Motivation
Notice: Trying to access array offset on value of type bool in menu_breadcrumb_init() (line 314 of .../menu_breadcrumb/menu_breadcrumb.module).
Steps to reproduce
function menu_breadcrumb_init() {
$is_front = drupal_is_front_page();
if (variable_get('menu_breadcrumb_determine_menu', 1) && !$is_front) {
// Find the set of menus containing a link for the current page.
$menu_item = menu_get_item();
$result = db_query("SELECT mlid, menu_name FROM {menu_links} WHERE link_path = :menu_item", array(':menu_item' => $menu_item['href']));
menu_get_item() can return false here, which causes the error.
Proposed resolution
Add a check and return early in this case.
Comments
Comment #2
solideogloria commentedComment #3
solideogloria commentedComment #4
bceyssensSeems to do the trick. +1
Comment #5
justinreynolds commentedthis fixes the issue for me as well on php 7.4.18.
Comment #6
xurizaemonThanks solideogloria, this looks good and should work AFAICT.
I'm unsure though about return false - is that what we should do from a
hook_init()implementation?None of core's
hook_init()implementations return values in any case.I don't believe the return codes are used (_drupal_bootstrap_full()) and return false suggests the return value is meaningful, so IMO
return;would be more correct with the same results.Comment #7
solideogloria commentedComment #8
vladimirausThanks for the commit. Applies and works!
Comment #10
xurizaemonThanks all! Committed to 7.x-1.x.