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

  1. Activate layout_builder
  2. Create a vocabulary and term
  3. View the term page

Comments

parijke created an issue. See original summary.

cilefen’s picture

Priority: Normal » Major

Is it reproducible on a clean install?

parijke’s picture

Yes, I just did it on Acquia cloud

cilefen’s picture

This is definitely major priority.

tim.plunkett’s picture

Version: 8.5.1 » 8.6.x-dev
Issue tags: +Needs tests

The 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.

tim.plunkett’s picture

Status: Active » Needs review
StatusFileSize
new2.63 KB

Still needs to write tests for this.

japerry’s picture

Issue tags: +Nashville2018
wjackson’s picture

Status: Needs review » Needs work

After 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:

  1. Enable Layout Builder and dependencies
  2. Create a new Taxonomy Vocabulary
  3. Create a new term for the vocabulary created in the previous step.
  4. Visit the taxonomy term page to view the error

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tim.plunkett’s picture

Issue tags: -Nashville2018
larowlan’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new1.47 KB

Here's a test, but it passes.
Is this still an issue?

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett
Issue tags: +sprint
StatusFileSize
new1.16 KB
new1.81 KB

Since 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.

Status: Needs review » Needs work

The last submitted patch, 12: 2959132-taxo-12.patch, failed testing. View results

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
Status: Needs work » Needs review
StatusFileSize
new3.38 KB
new3.32 KB

We 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.

Status: Needs review » Needs work

The last submitted patch, 14: 2959132-taxo-13.patch, failed testing. View results

tim.plunkett’s picture

The 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.

tim.plunkett’s picture

Status: Postponed » Needs review
StatusFileSize
new768 bytes
new1.63 KB
new2.31 KB

Above issue went in. Still have this fix.

The last submitted patch, 17: 2959132-taxo-17-FAIL.patch, failed testing. View results

tim.plunkett’s picture

Opened #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

tim.plunkett’s picture

Status: Needs review » Postponed
Issue tags: +Blocks-Layouts

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

tim.plunkett’s picture

Issue tags: -sprint

Removing tag as this is still postponed

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

pameeela’s picture

Status: Postponed » Closed (outdated)
Issue tags: +Bug Smash Initiative

I 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.

larowlan’s picture

Status: Closed (outdated) » Closed (cannot reproduce)

I guess its CNR now?

pameeela’s picture

Sure, 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 :)

larowlan’s picture

👍

tokosefi’s picture

is 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)

tokosefi’s picture

gmoraleb’s picture

The 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.