Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not.

Created on 5 February 2023, almost 2 years ago
Updated 14 September 2023, over 1 year ago

Problem/Motivation

Drupal 10.0.3 and PHP 8.2. I have following error when I try refresh thumbnails:

Wystąpił niespodziewany błąd. Proszę spróbować później.

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\QueryAggregate->prepare() (Line: 25)
Drupal\Core\Entity\Query\Sql\QueryAggregate->execute() (Line: 54)
Drupal\media_thumbnails\Batch\RefreshBatch::count() (Line: 33)
Drupal\media_thumbnails\Form\MediaThumbnailRefreshForm->getDescription() (Line: 45)
Drupal\Core\Form\ConfirmFormBase->buildForm()
call_user_func_array() (Line: 534)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 281)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 74)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 681)
Drupal\Core\DrupalKernel->handle() (Line: 19)
🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇵🇱Poland bronismateusz

Live updates comments and jobs are added and updated live.
  • PHP 8.2

    The issue particularly affects sites running on PHP version 8.2.0 or later.

Sign in to follow issues

Comments & Activities

  • Issue created by @bronismateusz
  • I also have this problem, but it doesn't seem limited to one module.
    Every time I try to delete something, it occurs (deleting a node, taxonomy term, menu item, ...). So I would think it's a core issue, although in this post ( https://www.drupal.org/project/drupal/issues/3318457 💬 QueryException: Entity queries must explicitly set whether the query should be access checked or not Closed: works as designed ) it is explicitly said that's not the case.

  • 🇬🇧United Kingdom darren.fisher

    Also experiencing this issue with Drupal 10, PHP 8.2. Thumbnails are not generating and trying to visit the refresh UI results in:

    The website encountered an unexpected error. Please try again later.
    
    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\QueryAggregate->prepare() (Line: 25)
    Drupal\Core\Entity\Query\Sql\QueryAggregate->execute() (Line: 54)
    Drupal\media_thumbnails\Batch\RefreshBatch::count() (Line: 33)
    Drupal\media_thumbnails\Form\MediaThumbnailRefreshForm->getDescription() (Line: 45)
    Drupal\Core\Form\ConfirmFormBase->buildForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 534)
    Drupal\Core\Form\FormBuilder->retrieveForm('media_thumbnails_refresh_form', Object) (Line: 281)
    Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
    Drupal\Core\Controller\FormController->getContentResult(Object, Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 163)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 74)
    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: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 686)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
    • drubb committed b3d25915 on 8.x-1.x
      Added missing query access check (#3339335)
      
  • Assigned to drubb
  • Status changed to Needs review over 1 year ago
  • 🇩🇪Germany drubb Sindelfingen

    I've just published a new dev version that should fix the problem. Please try it out!

  • Status changed to RTBC over 1 year ago
  • Tested and seems to work for me. It'd be nice to tag a new release for it.

  • 🇩🇪Germany drubb Sindelfingen

    Just tagged a new release.

  • Status changed to Fixed over 1 year ago
  • 🇩🇪Germany drubb Sindelfingen
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024