Problem/Motivation

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

Proposed resolution

Add condition to make sure the block is exist before calling the function.

    if ($block) {
      if ($role = $block->getThirdPartySetting('block_aria_landmark_roles', 'role')) {
        $variables['attributes']['role'] = $role;
      }

      if ($label = $block->getThirdPartySetting('block_aria_landmark_roles', 'label')) {
        $variables['attributes']['aria-label'] = $label;
      }
}
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

phuang07 created an issue. See original summary.

phuang07’s picture

Issue summary: View changes
FileSize
1.06 KB
phuang07’s picture

FileSize
1.06 KB
opdavies’s picture

Are there any particular steps needed to replicate the error?

opdavies’s picture

Status: Active » Postponed (maintainer needs more info)
dalemoore’s picture

I'm having the same issue. Didn't occur until I upgraded Drupal (now on 8.9.16) to my knowledge. Now get a WSOD with the following error message:

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

block_aria_landmark_roles_preprocess_block(Array, 'block', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('block', Array) (Line: 431)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 112)
__TwigTemplate_899185cd196b47053fdeb33a913bf0f679e3cfc79fd7557a660b13da93a4b353->doDisplay(Array, Array) (Line: 453)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 420)
Twig\Template->display(Array) (Line: 432)
Twig\Template->render(Array) (Line: 64)
twig_render_template('core/themes/stable/templates/field/field.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 431)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 444)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 61)
__TwigTemplate_12992e657effd79a4c559ee4d4a83ec1a09eb4e7e163589f5acca869320354a6->block_content(Array, Array) (Line: 214)
Twig\Template->displayBlock('content', Array, Array) (Line: 50)
__TwigTemplate_12992e657effd79a4c559ee4d4a83ec1a09eb4e7e163589f5acca869320354a6->block_paragraph(Array, Array) (Line: 214)
Twig\Template->displayBlock('paragraph', Array, Array) (Line: 39)
__TwigTemplate_12992e657effd79a4c559ee4d4a83ec1a09eb4e7e163589f5acca869320354a6->doDisplay(Array, Array) (Line: 453)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 420)
Twig\Template->display(Array) (Line: 432)
Twig\Template->render(Array) (Line: 64)
twig_render_template('modules/contrib/paragraphs/templates/paragraph.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('paragraph', Array) (Line: 431)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 55)
__TwigTemplate_899185cd196b47053fdeb33a913bf0f679e3cfc79fd7557a660b13da93a4b353->doDisplay(Array, Array) (Line: 453)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 420)
Twig\Template->display(Array) (Line: 432)
Twig\Template->render(Array) (Line: 64)
twig_render_template('core/themes/stable/templates/field/field.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 431)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 444)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array) (Line: 501)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 93)
__TwigTemplate_757dcc10e5da8040b666d69f7a6aada37e705db3085614b4e06c395233490513->doDisplay(Array, Array) (Line: 453)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 420)
Twig\Template->display(Array) (Line: 432)
Twig\Template->render(Array) (Line: 64)
twig_render_template('core/themes/stable/templates/content/node.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('node', Array) (Line: 431)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 200)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 573)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Similar issue: https://www.drupal.org/project/block_class/issues/2917683

Harry Slaughter’s picture

I've been testing the module. It worked fine when using the standard blocks config page (/admin/structure/block). But when I started to configure blocks via context module, I started getting the same error.

It seems to be choking on any null $block value. This patch is probably not an ideal solution, but it works.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Currently working on 2.0.0 release.

This has been PNMI for almost 2 years so unless it's still happening on 2.0.x branch going to close.

Feel free to reopen if you are still seeing issue.

Thanks!

o_timoshchuk’s picture

Status: Closed (outdated) » Active

I have the same issues with version 2.0.1. The patch #7 fixes it

smustgrave’s picture

Version: 8.x-1.4 » 3.0.x-dev

  • smustgrave committed b9c0cca9 on 3.0.x
    Issue #3219433 by phuang07, Harry Slaughter: Error: Call to a member...
smustgrave’s picture

Status: Active » Fixed

Ended up using an instance check.

Status: Fixed » Closed (fixed)

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