Problem/Motivation

After upgrading to PHP 7.4, I'm seeing a lot of these notices in our logs:

Notice: Trying to access array offset on value of type bool in toolbar_megamenu_tree_output() (line 189 of /code/profiles/commerce_kickstart/modules/commerce_kickstart/toolbar_megamenu/toolbar_megamenu.module).

Proposed resolution

I believe this notice comes up when menu_get_item() returns FALSE instead of an array. Similar issues from other projects:

https://www.drupal.org/project/drupal/issues/3085088
https://www.drupal.org/project/menu_breadcrumb/issues/3199016

To clear this up, we could check if $router_item is FALSE before trying to access array values.

Comments

hey_germano created an issue. See original summary.

hey_germano’s picture

Status: Active » Needs review
StatusFileSize
new967 bytes

Here's a patch.

rszrama’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new978 bytes

Thanks! Same treatment here.

  • rszrama committed 0558cd9 on 7.x-2.x
    Issue #3241668 by hey_germano, rszrama: Notice: Trying to access array...
rszrama’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.