I am getting two errors on my local Drupal 8 site.

First error: "The website encountered an unexpected error. Please try again later."

Second error: "Fatal error: Call to a member function access() on a non-object in ...block\src\BlockAccessControlHandler.php on line 124"

First error I get when php version is 7. Second error I get when php version is 5.


      elseif ($this->resolveConditions($conditions, 'and') !== FALSE) {
    // Delegate to the plugin.
    $block_plugin = $entity->getPlugin();
    try {
      if ($block_plugin instanceof ContextAwarePluginInterface) {
        $contexts = $this->contextRepository->getRuntimeContexts(array_values($block_plugin->getContextMapping()));
        $this->contextHandler->applyContextMapping($block_plugin, $contexts);
      $access = $block_plugin->access($account, TRUE);
    catch (MissingValueContextException $e) {
      // The contexts exist but have no value. Deny access without
      // disabling caching.
      $access = AccessResult::forbidden();

Line 124:

  $access = $block_plugin->access($account, TRUE);

I am not sure how to fix it. How can I fix the above errors so I can launch my site?


Added the code in settings. php and then reloaded the page.

$config['system.logging']['error_level'] = 'verbose';

The website encountered an unexpected error. Please try again later. Error: Call to a member function access() on null in Drupal\block\BlockAccessControlHandler->checkAccess() (line 124 of core\modules\block\src\BlockAccessControlHandler.php).

Drupal\block\BlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105)
Drupal\Core\Entity\EntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 365)
Drupal\Core\Entity\Entity->access('view', NULL, 1) (Line: 56)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 259)
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: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
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: 669)
Drupal\Core\DrupalKernel->handle(Object) (Line: 22)
  • The second error is caused by a bad block which is not linked to a plugin. What is behind the first generic 500 error? – 4k4 Aug 7 '19 at 20:32
  • How can I find out the reason behind the first generic 500 error? For the second error, I am not sure how to find out which block is the bad block because I cant access my site. – GreenTree Aug 8 '19 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.