Add support for aggregate entity queries

Created on 31 July 2024, 5 months ago

Problem/Motivation

I noticed this module overrides Drupal\Core\Entity\Query\Sql\Query, but not Drupal\Core\Entity\Query\Sql\QueryAggregate and Drupal\workspaces\EntityQuery\QueryAggregate.

Proposed resolution

Add overrides for these query classes.

✨ Feature request
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium dieterholvoet Brussels

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

Merge Requests

Comments & Activities

  • Issue created by @dieterholvoet
  • First commit to issue fork.
  • πŸ‡·πŸ‡΄Romania amateescu

    I've wanted to rewrite the entity query alters for a long time, and now that we have hook_entity_query_alter() in Drupal 10.3, I think it's time to bite the bullet and start using it :)

  • Merge request !31Refactor entity query alter. β†’ (Merged) created by amateescu
  • Pipeline finished with Skipped
    27 days ago
    #349771
  • πŸ‡·πŸ‡΄Romania amateescu

    My excitement with hook_entity_query_alter() was very short-lived.. core doesn't support it for aggregate queries, so I had to bring back most the ugly code I was trying to remove :/

    But the MR is still a slight improvement and easier to cleanup when the time comes, so merged into 3.x.

  • πŸ‡·πŸ‡΄Romania amateescu

    If anyone is interested, I opened a core issue to fix the missing bits: πŸ› Aggregate entity queries are missing the alter hooks Active

  • πŸ‡ΊπŸ‡ΈUnited States Maeglin

    It looks like something is still looking for the old Query class. I'm getting warnings similar to the following whenever a page loads after installing the latest update. This is after clearing the cache... twice.

    Warning: include(/var/www/drupal/web/modules/contrib/trash/src/EntityQuery/Sql/Query.php): Failed to open stream: No such file or directory in include() (line 576 of /var/www/drupal/vendor/composer/ClassLoader.php)

    #0 /var/www/drupal/web/core/includes/bootstrap.inc(108): _drupal_error_handler_real()
    #1 /var/www/drupal/vendor/composer/ClassLoader.php(576): _drupal_error_handler()
    #2 /var/www/drupal/vendor/composer/ClassLoader.php(576): include('...')
    #3 /var/www/drupal/vendor/composer/ClassLoader.php(427): Composer\Autoload\{closure}()
    #4 [internal function]: Composer\Autoload\ClassLoader->loadClass()
    #5 /var/www/drupal/web/core/lib/Drupal/Core/Entity/Query/QueryBase.php(507): class_exists()
    #6 /var/www/drupal/web/core/lib/Drupal/Core/Entity/Query/Sql/QueryFactory.php(50): Drupal\Core\Entity\Query\QueryBase::getClass()
    #7 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(625): Drupal\Core\Entity\Query\Sql\QueryFactory->get()
    #8 /var/www/drupal/web/core/modules/block_content/src/BlockContentUuidLookup.php(49): Drupal\Core\Entity\EntityStorageBase->getQuery()
    #9 /var/www/drupal/web/core/lib/Drupal/Core/Cache/CacheCollector.php(148): Drupal\block_content\BlockContentUuidLookup->resolveCacheMiss()
    #10 /var/www/drupal/web/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php(211): Drupal\Core\Cache\CacheCollector->get()
    #11 /var/www/drupal/web/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php(178): Drupal\block_content\Plugin\Block\BlockContentBlock->getEntity()
    #12 /var/www/drupal/web/core/lib/Drupal/Core/Block/BlockPluginTrait.php(127): Drupal\block_content\Plugin\Block\BlockContentBlock->blockAccess()
    #13 /var/www/drupal/web/core/modules/block/src/BlockAccessControlHandler.php(124): Drupal\Core\Block\BlockBase->access()
    #14 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php(109): Drupal\block\BlockAccessControlHandler->checkAccess()
    #15 /var/www/drupal/web/core/lib/Drupal/Core/Entity/EntityBase.php(329): Drupal\Core\Entity\EntityAccessControlHandler->access()
    #16 /var/www/drupal/web/core/modules/block/src/BlockRepository.php(63): Drupal\Core\Entity\EntityBase->access()
    #17 /var/www/drupal/web/core/modules/block/src/Plugin/DisplayVariant/BlockPageVariant.php(138): Drupal\block\BlockRepository->getVisibleBlocksPerRegion()
    #18 /var/www/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(270): Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build()
    #19 /var/www/drupal/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(128): Drupal\Core\Render\MainContent\HtmlRenderer->prepare()
    #20 /var/www/drupal/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse()
    #21 /var/www/drupal/vendor/symfony/event-dispatcher/EventDispatcher.php(246): Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
    #22 /var/www/drupal/vendor/symfony/event-dispatcher/EventDispatcher.php(206): Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}()
    #23 /var/www/drupal/vendor/symfony/event-dispatcher/EventDispatcher.php(56): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
    #24 /var/www/drupal/vendor/symfony/http-kernel/HttpKernel.php(188): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
    #25 /var/www/drupal/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #26 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
    #27 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #28 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #29 /var/www/drupal/web/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
    #30 /var/www/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
    #31 /var/www/drupal/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #32 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #33 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #34 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #35 /var/www/drupal/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
    #36 /var/www/drupal/web/core/lib/Drupal/Core/DrupalKernel.php(709): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
    #37 /var/www/drupal/web/index.php(19): Drupal\Core\DrupalKernel->handle()
    #38 {main}

  • πŸ‡·πŸ‡΄Romania amateescu

    @maeglin, that looks like an apcu/file cache issue, have you tried restarting the web server? Or deleting the trash module's directory and reinstalling it with composer?

  • πŸ‡ΊπŸ‡ΈUnited States Maeglin

    Ah... restarting php-fpm sorted it. Thanks!

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

Production build 0.71.5 2024