Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.
When the layout_builder module is enabled, trying to view a term page crashes with:
Drupal\Component\Plugin\Exception\ContextException: Assigned contexts were not satisfied: entity in Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() (line 101 of /var/www/html/web/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php).
Steps to reproduce
- Activate layout_builder
- Create a vocabulary and term
- View the term page
Comment | File | Size | Author |
---|---|---|---|
#17 | 2959132-taxo-17-PASS.patch | 2.31 KB | tim.plunkett |
#17 | 2959132-taxo-17-FAIL.patch | 1.63 KB | tim.plunkett |
#17 | 2959132-taxo-17-interdiff.txt | 768 bytes | tim.plunkett |
#14 | 2959132-taxo-13.patch | 3.32 KB | tim.plunkett |
#14 | 2959132-taxo-13-interdiff.txt | 3.38 KB | tim.plunkett |
Comments
Comment #2
cilefen CreditAttribution: cilefen at Institute for Advanced Study commentedIs it reproducible on a clean install?
Comment #3
parijke CreditAttribution: parijke as a volunteer commentedYes, I just did it on Acquia cloud
Comment #4
cilefen CreditAttribution: cilefen at Institute for Advanced Study commentedThis is definitely major priority.
Comment #5
tim.plunkettThe underlying error is that the caches aren't being cleared correctly, either when creating the vocab or term.
drush cr
"fixed it" in the short term.Comment #6
tim.plunkettStill needs to write tests for this.
Comment #7
japerryComment #8
wjackson CreditAttribution: wjackson at Kanopi Studios commentedAfter applying the patch, the error described still appears to exist.
As @tim.plunkett mentioned, clearing the caches will resolve the issue. However the patch does not appear to have any affect.
Screenshot of error
Steps to reproduce:
Comment #10
tim.plunkettComment #11
larowlanHere's a test, but it passes.
Is this still an issue?
Comment #12
tim.plunkettSince the opt-in issue, we need to actually turn it on for that display (and in this case, create a display at all).
This gets the
Drupal\Component\Plugin\Exception\ContextException: Assigned contexts were not satisfied: entity in Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() (line 121 of core/lib/Drupal/Core/Plugin/Context/ContextHandler.php).
The patch I had earlier seems to be unrelated? Or at least not enough on its own.
Working on this.
Comment #14
tim.plunkettWe already clear on field creation. But what were missing was bundle creation (which results in needing new field blocks for the base fields).
The bug is only reproducible while the Views module is installed.
This is because views_field_default_views_data() primed several caches early on, and they were not being cleared correctly.
While
\Drupal\Core\Entity\EntityBundleListener::onBundleDelete()
correctly cleared the field map,\Drupal\Core\Entity\EntityBundleListener::onBundleCreate()
did not.Furthermore, while every other cacheSet() and the clearCachedFieldDefinitions() call in EntityFieldManager used
entity_field_info
as a cache tag, field map did not.I removed the unnecessary parts of the test and added a check for the actual output.
Comment #16
tim.plunkettThe failure in the last patch is from the caching changes, which I also suggested as a solution on #2994398: Not properly clearing EntityFieldManager's fieldMap leads to fatals, often after migration or bundle creation.
Postponing on that for now.
Comment #17
tim.plunkettAbove issue went in. Still have this fix.
Comment #19
tim.plunkettOpened #3001284: Allow plugin derivers to specify cache tags for their definitions for a way to fix this without continuing to add more hooks clearing the block definition cache
Comment #20
tim.plunkettComment #22
tim.plunkettRemoving tag as this is still postponed
Comment #25
pameeela CreditAttribution: pameeela commentedI can't reproduce this on a fresh install, tried twice. The steps are pretty simple so I don't think I'm missing anything?
Going to close but if anyone has updated steps feel free to update the issue summary and set back to Postponed.
Comment #26
larowlanI guess its CNR now?
Comment #27
pameeela CreditAttribution: pameeela commentedSure, I usually use outdated it if it could be reproduced at one point and there is no obvious duplicate where it was fixed, but closed either way :)
Comment #28
larowlan👍
Comment #29
tokosefi CreditAttribution: tokosefi commentedis this same for me? WHen I click on product in taxonomy I get this error
The website encountered an unexpected error. Please try again later.
Drupal\Component\Plugin\Exception\ContextException: Assigned contexts were not satisfied: entity in Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() (line 145 of core/lib/Drupal/Core/Plugin/Context/ContextHandler.php).
Drupal\layout_builder\SectionComponent->getPlugin(Array) (Line: 70)
Drupal\layout_builder\Event\SectionComponentBuildRenderArrayEvent->__construct(Object, Array, ) (Line: 89)
Drupal\layout_builder\SectionComponent->toRenderArray(Array, ) (Line: 88)
Drupal\layout_builder\Section->toRenderArray(Array) (Line: 316)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildSections(Object) (Line: 275)
Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple(Array) (Line: 340)
Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 282)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 239)
Drupal\Core\Entity\EntityViewBuilder->build(Array)
call_user_func_array(Array, Array) (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 788)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 374)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 243)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 132)
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: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
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: 50)
Drupal\ban\BanMiddleware->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comment #30
tokosefi CreditAttribution: tokosefi commentedi tried https://www.drupal.org/files/issues/2018-09-19/2959132-taxo-17-PASS.patch and nothing is fixed
Comment #31
gmoraleb CreditAttribution: gmoraleb at NTT DATA commentedThe patch https://www.drupal.org/files/issues/2018-09-19/2959132-taxo-17-PASS.patch is not fixing the issue on my site. Drupal version 9.5.11.