Problem/Motivation
After updating the module from version 3.4 to 3.5 with its sub-module purge_drush enabled an exception is thrown (see below).
Steps to reproduce:
- Take a website running on either D9 or D10 core
- Install v3.4 of this module:
$ composer require 'drupal/purge:3.4' - Enable the main module and one of its sub-modules:
$ drush en purge purge_drush - Set up the site's purging system as follows:

- Upgrade to v3.5 of this module:
$ composer require 'drupal/purge:3.5' - Run either
$ drush cronor$ drush p:queue-work(basically anything that would process the queue) - Outcome:
PHP Fatal error: Uncaught TypeError: Drupal\Core\Database\StatementWrapperIterator::__construct(): Argument #2 ($clientConnection) must be of type object, null given, called in {docroot}/core/lib/Drupal/Core/Database/Connection.php on line 527 and defined in {docroot}/core/lib/Drupal/Core/Database/StatementWrapperIterator.php:53 thrown in {docroot}/core/lib/Drupal/Core/Database/StatementWrapperIterator.php on line 53 Stack trace: #0 {docroot}/core/lib/Drupal/Core/Database/Connection.php(527): Drupal\Core\Database\StatementWrapperIterator->__construct(Object(Drupal\mysql\Driver\Database\mysql\Connection), NULL, 'SELECT COUNT(*)...', Array, false) #1 {docroot}/core/lib/Drupal/Core/Database/Connection.php(787): Drupal\Core\Database\Connection->prepareStatement('SELECT COUNT(*)...', Array) #2 {docroot}/core/lib/Drupal/Core/Database/Query/Select.php(525): Drupal\Core\Database\Connection->query('SELECT COUNT(*)...', Array, Array) #3 {docroot}/modules/contrib/purge/src/Plugin/Purge/Queue/DatabaseQueue.php(112): Drupal\Core\Database\Query\Select->execute() #4 {docroot}/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(473): Drupal\purge\Plugin\Purge\Queue\DatabaseQueue->numberOfItems() #5 {docroot}/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(209): Drupal\purge\Plugin\Purge\Queue\QueueService->numberOfItems() #6 {docroot}/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(345): Drupal\purge\Plugin\Purge\Queue\QueueService->commit() #7 {docroot}/modules/contrib/purge/modules/purge_drush/src/Commands/PurgeDrushCommands.php(1131): Drupal\purge\Plugin\Purge\Queue\QueueService->destruct() #8 [internal function]: Drupal\purge_drush\Commands\PurgeDrushCommands->__destruct() #9 {main}
Proposed resolution
Based on @japerry's response in #3394310-8: Plugin (drush_purge_queue_work) instance class "DrushQueueWorkProcessor" does not exist we plan to restore those plugins in the sub-module as a workaround quickfix.
Remaining tasks
Beside that we still need to figure out a way to show them as deprecated so sites start using the new plugins instead.
User interface changes
n. a.
API changes
n. a.
Data model changes
n. a.
Original issue title
Queue throws error when there is a varnish purger configured.
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | 3397227-22-purge-setup.png | 47.77 KB | baluertl |
Issue fork purge-3397227
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
Comment #2
nicxvan commentedDigging in a bit this issue is occurring when numberOfItems is called in web/modules/contrib/purge/src/Plugin/Purge/Queue/DatabaseQueue.php.
When I run cron it is run twice and the first time it returns an integer as expected, the second time it returns nothing and the error is thrown.
Comment #3
nicxvan commentedComment #4
nicxvan commentedComment #5
nicxvan commentedIt also happens when config import happens and there is config imported
Comment #6
nicxvan commentedThis is killing several pipelines. After further investigation it occurs on drush commands updb, cim, or cron when something needs to execute. So anything related to queues.
It occurs when a Varnish purger is set, if I delete the varnish purger entity then it works as expected.
Comment #7
nicxvan commentedComment #8
nicxvan commentedI think I forgot one big thing, this started after updating to Drupal 10
Comment #9
pasive commentedSame for us - similar problem.
We resolved it by downgrading to previous version 3.4.0.
Site runs on the latest Drupal 9 version
Comment #10
alfattal commentedI agree with @pasive. I'm on Drupal 10 and the issue happened when I upgraded the module to version 3.5. Downgrading to the previous version resolved the issue for me.
Comment #11
nicxvan commentedDid you downgrade to the rc or to 3.4?
Comment #12
nicxvan commentedNevermind, the RC and 3.5 are identical, so it must be 3.4
Comment #13
nicxvan commentedI went through the changes that occurred between 3.4 and 3.5 and I have a theory. First I grabbed the queue changes, I don't think these are the cause of the issue, but I'll list them here for convenience:
https://git.drupalcode.org/project/purge/-/commit/75afeb4fc2b28c8e782410...
https://git.drupalcode.org/project/purge/-/commit/a21be456066026d96c4462...
https://git.drupalcode.org/project/purge/-/commit/3a6a46f76d20617bbb9827...
I suspect the issue is this though: https://git.drupalcode.org/project/purge/-/commit/0cdda1784393ddd55bc1aa...
purge_drush was deprecated, and part of that was hiding the module, but nothing was done in an update hook to disable it so it's still enabled on sites, it just does not show up in the list. I suspect that hiding the module and adding the functions to the core module, but not uninstalling it is what is causing the issues.
https://git.drupalcode.org/project/purge/-/commit/0cdda1784393ddd55bc1aa...
I tested this by manually disabling purge drush and I do not get the error any longer.
Comment #14
japerryHuh interesting.... the reason why its not removed is that when you delete a submodule it will cause a WSOD without manual db intervention. Therefore for the entire 3.x branch, the module needs to remain, even if we have it hidden.
The reason why we didn't automatically disable it is because sites could have been relying on the old namespaces, and disabling the module will kill their code. But in theory it should have worked along side the new modules even if enabled.
For API purposes, it should be using the libraries within purge itself. So its odd that its failing. I'll prioritize some time in the next weeks to look at it.
Comment #15
nicxvan commentedDisabling it manually seemed to fix the issue though I had to add the drush processor again to my config.
Comment #16
baluertlComment #17
baluertlComment #18
baluertlIn an effort of trying to clean up the big picture a bit let me summarize the situation:
purge_drushsubmodule (as it worked for @nicxvan in #15) eliminates the error on your environments as well? If it does then we can keep believing that your issue relates to the originally reported one.varnish_purgeas mentioned above) are involved in causing the issue? Or was it only an early guess from OP which became obsolete to the current state of our knowledge?@all if you could paste here in a comment the result of the
$ drush pdiacommand that would help a lot to see in which combination are our Purge configurations set up.Intending to ease the situation, I separated all these changes into the same folder structure on a per-file basis.
Comment #19
baluertlComment #20
alfattal commented@Balu Ertl In my case, I can confirm that disabling
purge_drushand then, upgrade to 3.5 eliminated the error. I tried first to upgrade and then, manually disablepurge_drush, but that DIDN'T eliminate the error.Update: I started to get different errors when attempt to sync the database
Comment #21
nicxvan commentedFor number 1 I highlighted those cause they had to do with the queue service and drush.
I suspect 9 and 10 are related cause they are all queue service
I don't think purge_varnish is related, I think that was a red herring
I think the steps to reproduce would be:
Install 3.4
Enable purge_drush
Set up drush processor
Enable varnish purge
Set up purger
Use core queuer and database queue
Upgrade to 3.5
Run drush cron or anything that would process the queue.
Comment #22
baluertlComment #24
baluertlI try to fix the issue by relocating the update hook enforcing the cache clear from the sub-module to the parent if it's being invoked with a higher chance during an update process.
@all would you mind testing on your environments if this solves the exceptions?
Comment #25
nicxvan commentedI cannot test since I manually updated my config. I don't think this will work though. I think you need something that clears definitions like this:
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Plugin%21...
Since the plugin location changes.
We might need to uninstall the purge_drush module instead of just hiding it too.
I'm not sure if config needs to be changed.
Comment #26
japerryI think this issue is tangentially related: https://www.drupal.org/i/3391383 -- we need to handle disappearing plugins better. Maybe some of the work in the patch there can be used to make handling the missing drush plugins uninstall correctly?
Comment #27
nicxvan commentedThat makes sense.
Just to clarify how I fixed it on my site.
1. Remove processor options from my purgers for all env (using config split)
2. Uninstall purge_drush
3. Add the drush processor back to all env (using config split)
4. Export config and save for all env
This fixed the issue for my site.
Comment #28
dotmundo commentedCan you explain what "config split" means and why this was neccessary. Thanks!!!
Comment #29
lykyd commentedConfig split is a module that allows to have different config files applying for different environment (ex: local/test/production environment). If you don't use this module then you just make import and export of the same config files with no environment specificity.
@balu ertl
The answer in my case was no,
drupal_flush_all_caches();it didn't solve it.And unfortunately the manual solution of @nicxvan (#25) isn't something I can do on each of my environment. I can only do that on local.
So I'm still looking for a solution at the moment.
Comment #30
japerryAnywhere we're creating a new instance of the plugin, ($this->pluginManager->createInstance) we're likely needing to wrap them:
Comment #31
baluertlComment #32
baluertlAlthough @japerry said in #14:
After a couple of days of exploration, I would revisit the above statement. In light of the number of people who had expressed their difficulties due to keeping the sub-module still installed, I believe that those who still rely on a piece of non-functional placeholder code should be a smaller minority. So I concluded that playing by Drupal's own terms is the safest we can do here. Just as ticket title suggests my solution disables the then-non-existent
purge_drushsub-module during the update process.Steps as I tested:
$ composer update drupal/purge$ composer require "drupal/purge:dev-3397227-update-to-3.5 as 3.x-dev" -W$ drush updbOR$ drush devel:reinstall purge$ drush p:queue-workMy last commit technically automates the steps that @nicxvan has shared in #27 with the difference that you don't need to manually disable the sub-module before the update process.
Comment #33
nicxvan commentedThanks, does this add the new drush processor automatically? Or does this just allow the new core plugin to take over?
Comment #34
baluertlAs it turned out during our recent call with Jakob, I was missing one key information: the reason why he would prefer avoiding uninstalling the sub-module. If some custom or contrib code depends on these Drush commands, then that would cause them a functionality loss. Of course, we can not know if any custom code relies on them among the 30k installation base. However, regarding the contrib space: I did minimal research and went through the modules appearing on the Purge ecosystem list. Only two projects,
akamaiandpurge_controloffer any Drush command plugins (here and here) but none of them has anything to do with our sub-module.In case module maintainers prioritize backward compatibility then such a code refactoring should be taken as a breaking change. Then this MR could be merged onto a newly opened
4.xbranch I think.@nicxvan Now tested again. Performing the steps above (and
$ drush ccto empty the plugin cache) leaves the processor plugin instance intact. The only change in site configuration you should see is the removal of this line:Comment #35
gauravjeet commentedJust clearing cache after deploying 3.5 to the server does resolve the issue for us. We did not disable purge_drush module.
Comment #37
japerryI spent some time on this today and there are a few things to point out:
1) The original 3.5 code enabled ALL drush plugins by default. Only 3 were supposed to be 'enable_by_default':
I don't -think- enabling the other plugins by default would cause the errors in the database query, but its untested, so who knows that could be it.
2) The 'enable_by_default' is sorta messy with purge. It means plugins are enabled by the mere existence of the module. This means that for those using the above drush commands (and associated plugins), they will DISAPPEAR if you disable purge_drush. You must manually re-enable the modules via the other drush commands (p:processor-add drush_purge_queue_work) or via purge ui.
3) The purge_drush module, with the above PR (purge_drush_fix) only serves to enable those three plugins by default.
4) The plugin cache gets automatically rebuilt when you run updb and have purge_drush enabled or if you manually disable purge_drush and run manually run updb. The classes are pointing to the purge core src directory. The command classes in purge_drush effectively do nothing, with the exception of those who may have extended them in their own custom commands and added annotations.
I'll give this a few weeks (since its christmas 2023) and then commit it if I don't see any responses.
Comment #38
nicxvan commentedI think one thing to keep in mind is purge_drush should at least be unhidden and marked as deprecated / remove.
One of the reasons it took so long for me to debug initially was the module was hidden from the module pages cause it's marked as hidden.
Comment #39
alfattal commentedI've tested the two PRs and still getting the error message when running
drush cronordrush p:queue-work.Comment #40
alfattal commentedComment #41
alfattal commented@balu-ertl Regarding your comment in #18, I think you're right. After revisiting this issue, I realized that it was caused by an old patch that is still sitting in my composer.jason file. After removing this patch, I was able to upgrade to version 3.5 without any issue.
Comment #42
tahiche commentedI'm getting the same database connection errors as pointed above:
As far as i can tell, this error started happening at some point and i canñt get it go go away.
I've tried downgrading to purge 3.4 from 3.6 but i'm still getting te error. Also applying patches in this post has not solved the issue.
The error comes up during config-import or any operation invlving my processor, which in my case is varnish_purger.
If i disabel the Varnish Purger processor i get no error. As soon as i enable it via UI or config import i get the error.
I'm clearing the purge cache on node update via a node_update hook, so in fact this is blocking content editing.
Step debugging the code everything seems normal, i can't find the exact spot where this exception happens.
It also happens on drush cr.
Seems to be some query on cache_config table that is passing a null connection. I guess it has to do with the purge_drush module as it seems very similar. But I'm lost here.
protected readonly Drupal\Core\Database\Connection $connection = ... }; protected $needsCleanup = FALSE; private $serverVersion = NULL }, $clientConnection = NULL, $query = 'SELECT "cid", "data", "created", "expire", "serialized", "tags", "checksum" FROM "SITE-PREXIX_cache_config" WHERE "cid" IN ( :cids__0 ) ORDER BY "cid"', $options = [], $rowCountEnabled = FALSE) /var/www/site/web/core/lib/Drupal/Core/Database/Connection.php:557