Drupal 10 Access Check Issue

Created on 22 June 2023, about 1 year ago
Updated 17 November 2023, 8 months ago

Problem/Motivation

When trying to display content that uses this module throws the following error:

Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck(). in Drupal\Core\Entity\Query\Sql\Query->prepare() (line 141 of /var/www/docroot/core/lib/Drupal/Core/Entity/Query/Sql/Query.php).

Proposed resolution

Looks like it's in Content.php in this query

$query = \Drupal::entityQuery('date_content')
        ->condition('type', $bundle)
        ->condition('parent_id', $entity->id())
        ->condition('parent_type', $entity->getEntityTypeId())
        ->condition('field_name', $field_name)
        ->condition('field_delta', $options['delta'])
      $existing = $query->execute();

MR headed your way here in a minute.

๐Ÿ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States josh.fabean

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @josh.fabean
  • @joshfabean opened merge request.
  • Status changed to Needs review 11 months ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada mandclu
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia keshav.k

    keshavv โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia keshav.k

    It was missing one another entityQuery
    Added that into MR as well.

  • Seems the issue comes up here as well after upgrading to D10. Any news about the patch? Best, Andreas

    Here's my error message on a newly updated Drupal install (9.5.11 -> 10.1.4) when trying to view an event as product in commerce:

    Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck(). in Drupal\Core\Entity\Query\Sql\Query->prepare() (line 141 of core/lib/Drupal/Core/Entity/Query/Sql/Query.php).

    Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 86)
    Drupal\date_content\Plugin\DateAugmenter\Content->augmentOutput() (Line: 835)
    Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDefaultFormatter->augmentOutput() (Line: 155)
    Drupal\smart_date\Plugin\Field\FieldFormatter\SmartDateDefaultFormatter->viewElements() (Line: 89)
    Drupal\Core\Field\FormatterBase->view() (Line: 265)
    Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple() (Line: 268)
    Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay->buildMultiple() (Line: 339)
    Drupal\Core\Entity\EntityViewBuilder->buildComponents() (Line: 281)
    Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (Line: 238)
    Drupal\Core\Entity\EntityViewBuilder->build()
    call_user_func() (Line: 37)
    Drupal\commerce_product\ProductVariationFieldRenderer->renderFields() (Line: 60)
    Drupal\commerce_product\ProductVariationFieldRendererLayoutBuilder->renderFields() (Line: 96)
    Drupal\commerce_product\ProductViewBuilder->alterBuild() (Line: 291)
    Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (Line: 238)
    Drupal\Core\Entity\EntityViewBuilder->build()
    call_user_func_array() (Line: 111)
    Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 797)
    Drupal\Core\Render\Renderer->doCallback() (Line: 386)
    Drupal\Core\Render\Renderer->doRender() (Line: 204)
    Drupal\Core\Render\Renderer->render() (Line: 238)
    Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 592)
    Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 239)
    Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
    Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
    Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    call_user_func() (Line: 111)
    Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 187)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
    Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 191)
    Drupal\page_cache\StackMiddleware\PageCache->fetch() (Line: 128)
    Drupal\page_cache\StackMiddleware\PageCache->lookup() (Line: 82)
    Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
    Drupal\ban\BanMiddleware->handle() (Line: 270)
    Drupal\shield\ShieldMiddleware->bypass() (Line: 226)
    Drupal\shield\ShieldMiddleware->handle() (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
    Drupal\Core\DrupalKernel->handle() (Line: 19)

  • Had issues with my upgrade from D 9.5.11 to 10.1.14 but after a clean replay of the upgrade the problem persists. Using the module makes the page using it crash with said error messages. Unchecking "Enabled Date Augmenters" - "Content" in the display section of the page's Smart Date field disables the module and the page loads properly.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada mandclu

    @dgwolf did you try patching it with the changes in the MR?

  • Thanks for encouraging me to try the patch. It works, the page loads without a glitch. +1 for the MR!

  • Status changed to Fixed 8 months ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada mandclu

    I'll take that feedback as an RTBC, so merged in the changes. Will roll a new release shortly.

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

Production build 0.69.0 2024