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 …blocksrcBlockAccessControlHandler.php on line 124”
First error I get when php version is 7. Second error I get when php version is 5.
BlockAccessControlHandler.php:
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?
Update
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 DrupalblockBlockAccessControlHandler->checkAccess() (line 124 of coremodulesblocksrcBlockAccessControlHandler.php).
DrupalblockBlockAccessControlHandler->checkAccess(Object, 'view', Object) (Line: 105) DrupalCoreEntityEntityAccessControlHandler->access(Object, 'view', Object, 1) (Line: 365) DrupalCoreEntityEntity->access('view', NULL, 1) (Line: 56) DrupalblockBlockRepository->getVisibleBlocksPerRegion(Array) (Line: 137) DrupalblockPluginDisplayVariantBlockPageVariant->build() (Line: 259) DrupalCoreRenderMainContentHtmlRenderer->prepare(Array, Object, Object) (Line: 117) DrupalCoreRenderMainContentHtmlRenderer->renderResponse(Array, Object, Object) (Line: 90) DrupalCoreEventSubscriberMainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) call_user_func(Array, Object, 'kernel.view', Object) (Line: 111) DrupalComponentEventDispatcherContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 156) SymfonyComponentHttpKernelHttpKernel->handleRaw(Object, 1) (Line: 68) SymfonyComponentHttpKernelHttpKernel->handle(Object, 1, 1) (Line: 57) DrupalCoreStackMiddlewareSession->handle(Object, 1, 1) (Line: 47) DrupalCoreStackMiddlewareKernelPreHandle->handle(Object, 1, 1) (Line: 99) Drupalpage_cacheStackMiddlewarePageCache->pass(Object, 1, 1) (Line: 78) Drupalpage_cacheStackMiddlewarePageCache->handle(Object, 1, 1) (Line: 47) DrupalCoreStackMiddlewareReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52) DrupalCoreStackMiddlewareNegotiationMiddleware->handle(Object, 1, 1) (Line: 23) StackStackedHttpKernel->handle(Object, 1, 1) (Line: 669) DrupalCoreDrupalKernel->handle(Object) (Line: 22)