Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Getting Undefined index: menu_name randomly when clearing cache. Complete error message returned to: /admin/config/development/performance - Notice: Undefined index: menu_name in menu_block_theme_suggestions_menu() (line 52 of sites/mountwashington.org/modules/menu_block/menu_block.module). menu_block_theme_suggestions_menu(Array)
Running a second "Clear all caches" immediately afterwards doesn't return the Notice.
I'm thinking this will probably need a fix similar to 2759019.
I'm on Drupal 8.1.6 with a clean install of menu block
I'm on
Comment | File | Size | Author |
---|
Comments
Comment #2
shishirsuvarna CreditAttribution: shishirsuvarna at Intelliswift commentedHi,
Try this patch this might resolve the issue.
Comment #3
shishirsuvarna CreditAttribution: shishirsuvarna at Intelliswift commentedComment #4
rrrob CreditAttribution: rrrob at Chapter Three commentedDuplicate of #2759019: Undefined Index in menu_block_theme_suggestions_block() and MenuBlock->build()
Comment #5
JohnAlbinComment #6
JohnAlbinActually, this isn't a dupe.
However, I have no idea how this warning message would occur. The "menu" theme hook is defined to a have "menu_name" variable in drupal_common_theme(). So, theoretically, the menu_name variable will always be defined. no clue how it would become undefined in your setup. :\ Any thoughts?
In any event, the patch needs work; you can't create variables from within hook_theme_suggestions_HOOK().
Comment #7
monkeyhouse CreditAttribution: monkeyhouse commentedI get the error as well, but only if I have caching disabled for development purposes. In my case, it appears to have something to do with the admin toolbar.
Drupal - 8.1.8
Menu Block - 8.x-1.2
Comment #8
criscomI am also getting this error on a multilingual D8 site. It's is currently hard to say when it started to occur nor why. It could be related to https://www.drupal.org/node/2769705 and https://www.drupal.org/node/2780423 (all token module issues). Hope this helps to track the problem down.
Comment #9
thmohd CreditAttribution: thmohd commented#2 Solved it for me. Thanks
Comment #10
ChandeepKhosa CreditAttribution: ChandeepKhosa at 2Toucans commentedI ran into the error mentioned https://www.drupal.org/node/2759019, installed the patch in #11 and that error disappeared.
Afterwards I noticed the error on this page occurred on a page where I have inserted a view block via display suite into a content type. I'm not sure if this was happening as a result of the first patch appalied.
The patch above in #2 fixed this for me too
Comment #11
JohnAlbinAs I said in #6 above, the patch in #2 is not acceptable, please stop saying "works for me".
@monkeyhouse and @criscom: Thank you for the hints! I'll keep trying to reproduce.
Comment #12
duntuk CreditAttribution: duntuk commented#2 fixed the issue for me. Even applied it manually to 8.x-1.x-dev-2016-Sep-02 version (which had the same error).
Comment #13
JohnAlbinSeriously?
Comment #14
JohnAlbinI figured it out. When the requested menu tree contains no links, then
$this->menuTree->build($tree)
returns a collapsed render array that only contains a#cache
entry. Menu block was overriding the default#theme
entry to add a theme hook suggestion, but it was incorrectly doing that even when the render array didn't have a#theme
entry. That meant the menu theme hook was being fired without the proper variables, like menu_name.Comment #16
JohnAlbinComment #18
StryKaizerIt looks like this code is gone in 8.x-1.x HEAD.
Prolly related to the fact I'm experiencing this issue with latest head, or was this fixed using different code?
EDIT:
tried 5f09f6c too, which did not solve the issue in my case
Comment #19
JohnAlbinI just double checked and its definitely in 8.x-1.x. And in 8.x-1.4.
I had to alter these lines of code in #2795095: PHP Notice: Undefined index: #id when used with Context module, so maybe that's why it's confusing?
Please try 8.x-1.4 and verify if you are still having the problem.
Comment #20
joelpittetAssuming fixed since no reply.
Comment #22
douggreen CreditAttribution: douggreen as a volunteer commentedThis causes other problems, please see #3207832: Active menu item not showing as title if it has no children