Problem/Motivation

Upgraded from 9.5.11 to 10.1.4 on PHP 8.1.23 with drush 12.2.0.0. I'd like to be able to use the site again as I cannot get past the error messages. Please excuse me if I should have reported this elsewhere.

Steps to reproduce

After the upgrade I set the mysql isolation level to "READ-COMMITTED". Later I was trying to get rid of errors like

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

that seemed to be related to contrib modules and missing columns. Upgrading the honeypot module worked, and I filed a bug report for a second suspected module.

The site became unusable with the following actions: Enabled Layout builder, created a layout for the Article content type following a Specbee tutorial, so far not used on this testing instance. Trying to save the first LB formatted test article led to a fatal crash that I am unable to recover from.

I inserted a debug command into web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php in order to find a contrib module that might be the culprit (podaroks patch from https://www.drupal.org/node/3201242") but I could not identify any project and the error messages remain, e.g., when loading the start page:

Error: Call to undefined method Drupal\Core\Entity\Query\Sql\Query::getTables() in Drupal\Core\Entity\Query\Sql\Condition->compile() (line 46 of core/lib/Drupal/Core/Entity/Query/Sql/Condition.php).

Drupal\Core\Entity\Query\Sql\Query->compile() (Line: 81)
Drupal\Core\Entity\Query\Sql\Query->execute() (Line: 606)
Drupal\Core\Entity\EntityStorageBase->loadByProperties() (Line: 46)
Drupal\block_content\Plugin\Derivative\BlockContent->getDerivativeDefinitions() (Line: 101)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives() (Line: 87)
Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions() (Line: 291)
Drupal\Core\Plugin\DefaultPluginManager->findDefinitions() (Line: 181)
Drupal\Core\Plugin\DefaultPluginManager->getDefinitions() (Line: 22)
Drupal\Core\Plugin\DefaultPluginManager->getDefinition() (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 76)
Drupal\Component\Plugin\PluginManagerBase->createInstance() (Line: 62)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->initializePlugin() (Line: 57)
Drupal\block\BlockPluginCollection->initializePlugin() (Line: 80)
Drupal\Component\Plugin\LazyPluginCollection->get() (Line: 45)
Drupal\block\BlockPluginCollection->get() (Line: 83)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->setConfiguration() (Line: 99)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->addInstanceId() (Line: 55)
Drupal\Core\Plugin\DefaultSingleLazyPluginCollection->__construct() (Line: 34)
Drupal\block\BlockPluginCollection->__construct() (Line: 156)
Drupal\block\Entity\Block->getPluginCollection() (Line: 145)
Drupal\block\Entity\Block->getPlugin() (Line: 118)
Drupal\block\BlockAccessControlHandler->checkAccess() (Line: 105)
Drupal\Core\Entity\EntityAccessControlHandler->access() (Line: 314)
Drupal\Core\Entity\EntityBase->access() (Line: 63)
Drupal\block\BlockRepository->getVisibleBlocksPerRegion() (Line: 137)
Drupal\block\Plugin\DisplayVariant\BlockPageVariant->build() (Line: 270)
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: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
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)

# drush cr yields similar output although it had worked before:

23-Sep-2023 10:26:51 UTC] PHP Fatal error: Uncaught Error: Call to undefined method Drupal\Core\Entity\Query\Sql\Query::getTables() in /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php:46
Stack trace:
#0 /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(177): Drupal\Core\Entity\Query\Sql\Condition->compile()
#1 /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(81): Drupal\Core\Entity\Query\Sql\Query->compile()
#2 /var/www/html/web/core/modules/menu_link_content/src/Plugin/Deriver/MenuLinkContentDeriver.php(64): Drupal\Core\Entity\Query\Sql\Query->execute()
#3 /var/www/html/web/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(101): Drupal\menu_link_content\Plugin\Deriver\MenuLinkContentDeriver->getDerivativeDefinitions()
#4 /var/www/html/web/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(87): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives()
#5 /var/www/html/web/core/lib/Drupal/Core/Menu/MenuLinkManager.php(125): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
#6 /var/www/html/web/core/lib/Drupal/Core/Menu/MenuLinkManager.php(150): Drupal\Core\Menu\MenuLinkManager->getDefinitions()
#7 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php(90): Drupal\Core\Menu\MenuLinkManager->rebuild()
#8 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php(78): Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->menuLinksRebuild()
#9 [internal function]: Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->onRouterRebuild()
#10 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
#11 /var/www/html/web/core/lib/Drupal/Core/Routing/RouteBuilder.php(197): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#12 /var/www/html/web/core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php(83): Drupal\Core\Routing\RouteBuilder->rebuild()
#13 /var/www/html/web/core/includes/common.inc(518): Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild()
#14 /var/www/html/web/core/includes/utility.inc(41): drupal_flush_all_caches()
#15 /var/www/html/vendor/drush/drush/src/Commands/core/CacheRebuildCommands.php(66): drupal_rebuild()
#16 [internal function]: Drush\Commands\core\CacheRebuildCommands->rebuild()
#17 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
#18 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#19 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#20 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process()
#21 /var/www/html/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#22 /var/www/html/vendor/symfony/console/Application.php(1081): Symfony\Component\Console\Command\Command->run()
#23 /var/www/html/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand()
#24 /var/www/html/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun()
#25 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
#26 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
#27 /var/www/html/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run()
#28 /var/www/html/vendor/drush/drush/drush(4): require('...')
#29 /var/www/html/vendor/bin/drush(119): include('...')
#30 {main}
thrown in /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php on line 46

Fatal error: Uncaught Error: Call to undefined method Drupal\Core\Entity\Query\Sql\Query::getTables() in /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php:46
Stack trace:
#0 /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(177): Drupal\Core\Entity\Query\Sql\Condition->compile()
#1 /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(81): Drupal\Core\Entity\Query\Sql\Query->compile()
#2 /var/www/html/web/core/modules/menu_link_content/src/Plugin/Deriver/MenuLinkContentDeriver.php(64): Drupal\Core\Entity\Query\Sql\Query->execute()
#3 /var/www/html/web/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(101): Drupal\menu_link_content\Plugin\Deriver\MenuLinkContentDeriver->getDerivativeDefinitions()
#4 /var/www/html/web/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php(87): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDerivatives()
#5 /var/www/html/web/core/lib/Drupal/Core/Menu/MenuLinkManager.php(125): Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator->getDefinitions()
#6 /var/www/html/web/core/lib/Drupal/Core/Menu/MenuLinkManager.php(150): Drupal\Core\Menu\MenuLinkManager->getDefinitions()
#7 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php(90): Drupal\Core\Menu\MenuLinkManager->rebuild()
#8 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php(78): Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->menuLinksRebuild()
#9 [internal function]: Drupal\Core\EventSubscriber\MenuRouterRebuildSubscriber->onRouterRebuild()
#10 /var/www/html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
#11 /var/www/html/web/core/lib/Drupal/Core/Routing/RouteBuilder.php(197): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#12 /var/www/html/web/core/lib/Drupal/Core/ProxyClass/Routing/RouteBuilder.php(83): Drupal\Core\Routing\RouteBuilder->rebuild()
#13 /var/www/html/web/core/includes/common.inc(518): Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild()
#14 /var/www/html/web/core/includes/utility.inc(41): drupal_flush_all_caches()
#15 /var/www/html/vendor/drush/drush/src/Commands/core/CacheRebuildCommands.php(66): drupal_rebuild()
#16 [internal function]: Drush\Commands\core\CacheRebuildCommands->rebuild()
#17 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array()
#18 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback()
#19 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter()
#20 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process()
#21 /var/www/html/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute()
#22 /var/www/html/vendor/symfony/console/Application.php(1081): Symfony\Component\Console\Command\Command->run()
#23 /var/www/html/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand()
#24 /var/www/html/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun()
#25 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run()
#26 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun()
#27 /var/www/html/vendor/drush/drush/drush.php(139): Drush\Runtime\Runtime->run()
#28 /var/www/html/vendor/drush/drush/drush(4): require('...')
#29 /var/www/html/vendor/bin/drush(119): include('...')
#30 {main}
thrown in /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Condition.php on line 46
[warning] Drush command terminated abnormally.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

dgwolf created an issue. See original summary.

cilefen’s picture

Category: Bug report » Support request
Priority: Critical » Normal

I’m moving this to a support request because it seems this site wasn’t prepared for the upgrade. “Entity queries must explicitly set whether the query should be access checked or not” is a sure sign of that.

cilefen’s picture

What is the data type of the query property of the Condition class when this occurs? getTables is a public function of \Drupal\Core\Entity\Query\Sql\Query, which is what the property is supposed to be and what the exception indicates the property is.

cilefen’s picture

Title: Fatal error in Sql\Query::getTables() » Call to undefined method Drupal\Core\Entity\Query\Sql\Query::getTables() in Drupal\Core\Entity\Query\Sql\Condition->compile()
dgwolf’s picture

Thank you very much for your time and replies, cilefen!

I rolled back the upgrade and realized when repeating it that I accidentally had upgraded the Dynamic Entity Reference module from 8.x-1.16 to version to 3.1.0 instead of 4.0.0-alpha3 as suggested by the upgrade checker (seems my eyes had registered some version 3 one line above for one of the two other modules I had to take care of). I had managed to work around the ensuing composer messages, but this may have done more harm than anything.

Other than that the site seemed upgrade ready alright but ... the crashes occurred again upon saving a simple test page of the type Article and stopped after deactivating Admin Toolbar Content 1.3.12 that was, not rightfully so, it seems, flagged as _compatible_ in the upgrade status list. However, upgrading to the also recommended version 2.0.2 fixed this too.

It seems the site is OK now except for the error "Transaction isolation level READ-COMMITTED [...] The following table(s) do not have a primary key: contact_message. - May I ask, how do I find out to which module, core or contrib, the table contact_message belongs?

Best, Andreas

catch’s picture

#3373325: contact_message table does not have a primary key for contact_message, but this is more of a warning for that module than for you really, so you should be OK to wait for an update once it gets fixed there.

dgwolf’s picture

Thank you.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

quietone’s picture

Status: Active » Fixed

This has been resolved and can be closed.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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