Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297600

[regression] \Drupal\user\ContextProvider\CurrentUserContext broken for anonymous users

$
0
0

After updating my local d 8.5.7 to d 8.6.0 (with composer) and testing as anonymous the below error was blown in my face ! No such error when browsing drupal as authenticated user.

The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\Core\Plugin\Context\EntityContext::fromEntity() must implement interface Drupal\Core\Entity\EntityInterface, null given, called in pathToDrupal\d8root\core\modules\user\src\ContextProvider\CurrentUserContext.php on line 58 in Drupal\Core\Plugin\Context\EntityContext::fromEntity() (line 56 of core\lib\Drupal\Core\Plugin\Context\EntityContext.php).

Drupal\Core\Plugin\Context\EntityContext::fromEntity(NULL, Object) (Line: 58)
Drupal\user\ContextProvider\CurrentUserContext->getRuntimeContexts(Array) (Line: 79)
Drupal\Core\Plugin\Context\LazyContextRepository->getRuntimeContexts(Array) (Line: 91)
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: 184)
Drupal\page_cache\StackMiddleware\PageCache->fetch(Object, 1, 1) (Line: 121)
Drupal\page_cache\StackMiddleware\PageCache->lookup(Object, 1, 1) (Line: 75)
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: 665)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I found out it's caused by some of the enabled blocks which have their visibility restricted for some blocks by Roles + something else.
The error also was triggered by another custom basic block called "Message for anonymous" which has visibility set by Content types, Pages, and Roles.

  • I removed all restrictions but it didn't help.
  • I deleted the block and created a new one with only Roles restriction but that caused the error too!

A third custom basic block that's meant to be seen by certain roles also caused the error. Its visibility is restricted by Pages + Roles.
I removed the Roles restriction and kept the Pages only and that fixed it.

Two or more other blocks that caused the error too were restricted only by roles and the error was gone when I removed the restriction.

I hope someone can shed some light on how to fix this or what I should do to better manage it.

Thanks


Viewing all articles
Browse latest Browse all 297600

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>