Problem/Motivation

I get following error when trying to select an image from the media library on a content type.

Drupal\Component\Plugin\Exception\MissingValueContextException: Required contexts without a value: node in /var/www/html/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php:150 Stack trace: #0 /var/www/html/modules/contrib/block_visibility_groups/src/GroupEvaluator.php(98): Drupal\Core\Plugin\Context\ContextHandler->applyContextMapping() #1 /var/www/html/modules/contrib/block_visibility_groups/src/GroupEvaluator.php(64): Drupal\block_visibility_groups\GroupEvaluator->applyContexts() #2 /var/www/html/modules/contrib/block_visibility_groups/src/Plugin/Condition/ConditionGroup.php(68): Drupal\block_visibility_groups\GroupEvaluator->evaluateGroup() #3 /var/www/html/core/lib/Drupal/Core/Condition/ConditionManager.php(76): Drupal\block_visibility_groups\Plugin\Condition\ConditionGroup->evaluate() #4 /var/www/html/core/lib/Drupal/Core/Condition/ConditionPluginBase.php(85): Drupal\Core\Condition\ConditionManager->execute() #5 /var/www/html/core/lib/Drupal/Core/Condition/ConditionAccessResolverTrait.php(26): Drupal\Core\Condition\ConditionPluginBase->execute() #6 /var/www/html/core/modules/block/src/BlockAccessControlHandler.php(116): Drupal\block\BlockAccessControlHandler->resolveConditions() #7 /var/www/html/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php(109): Drupal\block\BlockAccessControlHandler->checkAccess() #8 /var/www/html/core/lib/Drupal/Core/Entity/EntityBase.php(329): Drupal\Core\Entity\EntityAccessControlHandler->access() #9 /var/www/html/core/modules/block/src/BlockRepository.php(63): Drupal\Core\Entity\EntityBase->access() #10 /var/www/html/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php(138): Drupal\block\BlockRepository->getVisibleBlocksPerRegion() #11 /var/www/html/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(270): Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() #12 /var/www/html/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare() #13 /var/www/html/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() #14 [internal function]: Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray() #15 /var/www/html/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func() #16 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(186): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() #17 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw() #18 /var/www/html/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(68): Symfony\Component\HttpKernel\HttpKernel->handle() #19 /var/www/html/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle() #20 /var/www/html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #21 /var/www/html/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #22 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle() #23 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass() #24 /var/www/html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle() #25 /var/www/html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #26 /var/www/html/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #27 /var/www/html/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle() #28 /var/www/html/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionHtmlSubscriber.php(166): Drupal\Core\StackMiddleware\StackedHttpKernel->handle() #29 /var/www/html/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php(119): Drupal\Core\EventSubscriber\DefaultExceptionHtmlSubscriber->makeSubrequest() #30 /var/www/html/core/lib/Drupal/Core/EventSubscriber/CustomPageExceptionHtmlSubscriber.php(71): Drupal\Core\EventSubscriber\CustomPageExceptionHtmlSubscriber->makeSubrequestToCustomPath() #31 /var/www/html/core/lib/Drupal/Core/EventSubscriber/HttpExceptionSubscriberBase.php(109): Drupal\Core\EventSubscriber\CustomPageExceptionHtmlSubscriber->on403() #32 [internal function]: Drupal\Core\EventSubscriber\HttpExceptionSubscriberBase->onException() #33 /var/www/html/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func() #34 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(239): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() #35 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(91): Symfony\Component\HttpKernel\HttpKernel->handleThrowable() #36 /var/www/html/modules/contrib/simple_oauth/src/HttpMiddleware/BasicAuthSwap.php(68): Symfony\Component\HttpKernel\HttpKernel->handle() #37 /var/www/html/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle() #38 /var/www/html/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle() #39 /var/www/html/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle() #40 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle() #41 /var/www/html/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass() #42 /var/www/html/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle() #43 /var/www/html/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() #44 /var/www/html/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() #45 /var/www/html/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle() #46 /var/www/html/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle() #47 /var/www/html/index.php(19): Drupal\Core\DrupalKernel->handle() #48 @main

Steps to reproduce

Not entirely sure how to reproduce this on a vanilla install.

Proposed resolution

See MR.

Remaining tasks

MR

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bramdriesen created an issue. See original summary.

bramdriesen’s picture

Adding a related issue, but not sure if that is the real underlaying problem.

bramdriesen’s picture

Status: Active » Needs review
damienmckenna’s picture

Status: Needs review » Reviewed & tested by the community

Thank you for providing that, I ran into it on a site that was using 2.0.x but when it went away when I upgraded to 2.1.x I thought I had just borked up a patch locally.

We'll get this out in a new release so the 2.0.x branch can be stable again.

aurora.luzzardi’s picture

StatusFileSize
new852 bytes
new84.17 KB

Hi, I'm moving this to needs work, after applying the diff with a patch (attached here), the blocks with multiple conditions did not show were they should.

I attached the image of my block_visibility_group configuration.

aurora.luzzardi’s picture

Status: Reviewed & tested by the community » Needs work
bramdriesen’s picture

the blocks with multiple conditions did show were they should.

What's the issue then? :-)

aurora.luzzardi’s picture

Sorry, I mistyped! They did not show as they should.
When should match the Request Path, is always false and not showing on the page.
Seems that is not properly handling the context for the Request Path condition

aurora.luzzardi’s picture

By testing here, seems that the early is causing the issue, it's not allowing to go to the second condition to allow match the RequestPath conditon

if ($context->getContextData()->getValue() === NULL) {
  return FALSE;
}

I changed here for testing:

         if (empty($contexts)) {
            continue;
          }

          $isEmptyContextData = TRUE;
          foreach ($contexts as $context) {
            if ($context->getContextData()->getValue() !== NULL) {
              $isEmptyContextData = FALSE;
            }
          }
          if ($isEmptyContextData) {
            continue;
          }

I will prepare the interdiff and a new patch in a few minutes to send here.

aurora.luzzardi’s picture

StatusFileSize
new2.18 KB
new2.04 KB

Here the interdiff patch and a fullpatch for the current 2.0 version.

aurora.luzzardi’s picture

Status: Needs work » Needs review
joevagyok’s picture

The patch in #11 looks good. We are using it on our project.

scottsawyer’s picture

Status: Needs review » Reviewed & tested by the community

I am using this on multiple sites, seems to do the trick. Thanks

jason.ullstam’s picture

I have also tested the patch from #11 and it is working for us. Any idea when this might get added to a release. I have hundreds of sites using this module and would prefer to not patch if possible.

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed
Parent issue: » #3500476: Plan for Block Visibility Groups v2.0.4

Thank you all for working through this bug and building a fix.

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.