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.
I am getting the following on a fresh install of menu_block:
Notice: Undefined index: region in Drupal\menu_block\Plugin\Block\MenuBlock->build() (line 152 of modules/contrib/menu_block/src/Plugin/Block/MenuBlock.php).
Notice: Undefined index: uuid in Drupal\menu_block\Plugin\Block\MenuBlock->build() (line 153 of modules/contrib/menu_block/src/Plugin/Block/MenuBlock.php).
Notice: Undefined index: region in menu_block_theme_suggestions_block() (line 15 of modules/contrib/menu_block/menu_block.module).
Notice: Undefined index: uuid in menu_block_theme_suggestions_block() (line 16 of modules/contrib/menu_block/menu_block.module).
Is anyone else getting the same issue? Seems like the 'region' and 'uuid' array key is not available in the $variables['elements']['#configuration']
array?
Comment | File | Size | Author |
---|---|---|---|
#22 | Screen Shot 2016-08-04 at 3.13.14 PM.png | 110.78 KB | osman |
#22 | Screen Shot 2016-08-04 at 3.13.49 PM.png | 120.83 KB | osman |
#22 | Screen Shot 2016-08-04 at 3.14.13 PM.png | 111.35 KB | osman |
#22 | Screen Shot 2016-08-04 at 3.14.31 PM.png | 133.89 KB | osman |
#18 | Screenshot 2016-08-02 14.30.40.png | 109.16 KB | 4alldigital |
Comments
Comment #2
ellioseven CreditAttribution: ellioseven commentedComment #3
ellioseven CreditAttribution: ellioseven commentedComment #4
ellioseven CreditAttribution: ellioseven commentedComment #5
ellioseven CreditAttribution: ellioseven commentedComment #6
Ramdas Gaikar CreditAttribution: Ramdas Gaikar at Intelliswift commentedHi ellioseven,
I am not able to reproduce this issue.
I am using Seven as admin and Bartik as default theme.
Comment #7
chrisfromredfinI am also just seeing this issue. I just installed 8.x-1.1 on an existing site.
Comment #8
chrisfromredfinComment #9
ellioseven CreditAttribution: ellioseven commentedI am submitting a patch that checks if the block has a correlating configuration entity. If so, it will load it up and pass the region and UUID to default configuration. Seems to be working for me, however doesn't look like any tests are available with the 8.x-1.1 branch.
Comment #10
4aficiona2 CreditAttribution: 4aficiona2 commentedI can confirm this. Just installed menu_block 8.x-1.1 on an existing site and I also get this notice / error.
Comment #11
chrisfromredfinThis patch seems to be working for me. I've re-rolled the patch from the module root instead of the Drupal root.
Comment #12
aleksipComment #13
jhuhta CreditAttribution: jhuhta commentedThe patch seems to be working fine for me too.
Comment #14
jlockhartThis solved the issue for us as well.
Comment #15
JeroenTPatch also fixed the problem for me.
Comment #16
JohnAlbinI can't reproduce this error. The region and uuid configuration are provided to all blocks in regions. Are you using a module to render a block outside of a normal page region?
Also, I'm testing on the latest Drupal 8.1.x core version with the standard installation profile. Which core version are you all using?
The configuration of the element is already provided in $variables['elements']['#configuration'], so the code feels redundant to me. Also, the patch doesn't grab _this_ block's config. It grabs the first menu_block config in the system; if you have more than 1 config, only 1 block will get the correct config.
Comment #17
4alldigital CreditAttribution: 4alldigital commentedI have this too. Looks like 'region' and 'uuid' are definitely missing from $this->configuration in MenuBlock.php. Have repeated/tested on 2 separate Drupal installs.
line 150:
Comment #18
4alldigital CreditAttribution: 4alldigital commentedAttached screen grab of KINT debug of $this->configuration immediately prior to use (see previous comment) . If this helps at all.
Comment #19
morenstratPatch from #11 does not fix the issue if you have two menu blocks in different regions because it always uses the first config entity.
Comment #20
dawehnerThe region should not be available as part of the configuration of a block. Block plugins are designed to be rendered outside of the block UI, so for example in panels.
In there you don't have a block entity for every block, but rather one big page_manager configuration for all the blocks.
Comment #21
osmanThere is a change record regarding region name being removed from `suggestions`:
Per-region block markup and per-region block templating feature removed
https://www.drupal.org/node/2011434
So, how does
menu_block_theme_suggestions_block()
incorporates region specific suggestions?(Not sure about
uuid
based suggestions though.)Also, when I try to output variables, none of the blocks I have (core, custom and menu blocks), populated
region
oruuid
keys:Comment #22
osmanComment #23
davebeach CreditAttribution: davebeach as a volunteer commentedI got this problem a few times; after I deleted structures related to menu_block. The only way I could correct the problem is to completely uninstall it. Then reinstall.
Also to avoid having this error out in production. In your settings.yml file (sites>default>settings.yml).
Uncomment:
$conf['error_level'] = 0;
To uninstall via drush:
drush sset system.maintenance_mode 1
Comment #24
JohnAlbin@osman Thank you for pointing to the change record! It looks like System menu block's were supposed to be able to get context (like region placement) with a follow-up patch, but they never did. :-(
Ugh. It was me who was using an extra module. Context module is stuffing those extra things into the config. I'll have to rip those theme hook suggestions out. :-p
Comment #25
generalredneckPretty sure you can recreate this using a panels page and rendering the block inside one of the regions in the layout.
Comment #26
becw CreditAttribution: becw at Palantir.net commentedI ran into this issue too. It sounds like the issue is that menu_block expects some contextual information for blocks that core does not provide, and that the patch in #11 adds that information. In my testing, this patch resolves the PHP notices.
I think that #11 just needs a review?
Comment #27
jamievereecken CreditAttribution: jamievereecken commentedPatch in #11 fixed the problem for me.
Comment #28
DamienMcKennaComment #29
chrisfromredfinI believe the consensus is the patch in #11 doesn't work for multiple menu blocks, as it hardcodes the delta [0].
Comment #30
DamienMcKennaFYI the patch in #11 appears to work as a bandaid for limited use cases, though clearly it needs some work. Sites that are experiencing this problem may wish to test out the patch, but it isn't guaranteed to fix the problem and may cause others.
Comment #31
JohnAlbinI've got the fix for this. Will commit shortly.
Comment #33
JohnAlbinComment #34
ChandeepKhosa CreditAttribution: ChandeepKhosa at 2Toucans commentedthanks a lot John, looking forward to removing the patch for this I had in my repo :)