When using some other contrib modules I found the following error in some pages causing WSOD:

The website encountered an unexpected error. Please try again later.
Error: Call to a member function getThirdPartySetting() on null in block_class_preprocess_block() (line 38 of modules/contrib/block_class/block_class.module).

Here is the code of that particular function:

/**
 * Implements hook_preprocess_HOOK().
 */
function block_class_preprocess_block(&$variables) {
  // Blocks coming from page manager widget does not have id.
  if (!empty($variables['elements']['#id'])) {
    $block = Block::load($variables['elements']['#id']);
    if ($classes = $block->getThirdPartySetting('block_class', 'classes')) { // line 38
      $variables['attributes']['class'][] = $classes;
    }
  }
}

It looks that the $block variable is null.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

juankvillegas created an issue. See original summary.

juankvillegas’s picture

Here is a patch that continues with the PHP logic only if the variable $block is not null.

Romixua’s picture

I have this problem with block_field module.
Just need to check if $block not empty.

Romixua’s picture

Status: Active » Needs review
pookmish’s picture

Just ran into this yesterday and #3 patch works for me.

pookmish’s picture

Status: Needs review » Reviewed & tested by the community
kyberman’s picture

Thank you for these patches. If possible, I would like to see patch #2 merged, because it's much more readable.

heshanlk’s picture

Working fine. Thanks

renatog’s picture

And guys. I checked and really works good.

  • RenatoG committed 0a39965 on 8.x-1.x authored by Romixua
    Issue #2917683 by juankvillegas, Romixua, pookmish, kyberman, RenatoG,...
renatog’s picture

Status: Reviewed & tested by the community » Fixed

Committed to the dev branch.

Thank you all.

Best,

Status: Fixed » Closed (fixed)

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