Error: Call to a member function getRegion() on null in twigsuggest_theme_suggestions_block()

Created on 29 April 2020, over 4 years ago
Updated 13 May 2020, over 4 years ago

I'm using the module Fixed Block Content which

provides a way of having permanent custom content blocks without broken instances if the block does not exist.

When Twig Template Suggester is enabled and I land on a page with a fixed block, I get this error:
Error: Call to a member function getRegion() on null in twigsuggest_theme_suggestions_block() (line 30 of modules/contrib/twigsuggest/twigsuggest.module).
The issue lies in the block not being loaded (NULL): $block = Block::load($variables['elements']['#id'])
Its ID comes in a different format: fixed_block_content:my__block_machine_name.

Adding a simple check sorts the issue. Patch attached.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇦🇺Australia elgandoz Canberra

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France dqd London | N.Y.C | Paris | Hamburg | Berlin

    This will cause undefined Arrey key (#id) error in Drupal 9.5 and higher.

Production build 0.71.5 2024