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:

  1. Take a website running on either D9 or D10 core
  2. Install v3.4 of this module: $ composer require 'drupal/purge:3.4'
  3. Enable the main module and one of its sub-modules: $ drush en purge purge_drush
  4. Set up the site's purging system as follows:

    Screenshot

  5. Upgrade to v3.5 of this module: $ composer require 'drupal/purge:3.5'
  6. Run either $ drush cron or $ drush p:queue-work (basically anything that would process the queue)
  7. 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.

CommentFileSizeAuthor
#22 3397227-22-purge-setup.png47.77 KBbaluertl

Issue fork purge-3397227

Command icon 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

nicxvan created an issue. See original summary.

nicxvan’s picture

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

nicxvan’s picture

Title: Queue throws error when varnish image purge is enabled » Queue throws error when varnish purger is unreachable
nicxvan’s picture

Title: Queue throws error when varnish purger is unreachable » Queue throws error when varnish purger exists
nicxvan’s picture

It also happens when config import happens and there is config imported

nicxvan’s picture

Priority: Normal » Major

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

nicxvan’s picture

Title: Queue throws error when varnish purger exists » Queue throws error when there is a varnish purger configured.
nicxvan’s picture

I think I forgot one big thing, this started after updating to Drupal 10

pasive’s picture

Same for us - similar problem.

PHP Fatal error:  Uncaught Error: Call to a member function prepare() on null in /var/www/web/core/lib/Drupal/Core/Database/StatementWrapper.php:51
Stack trace:
#0 /var/www/web/core/lib/Drupal/Core/Database/Connection.php(630): Drupal\Core\Database\StatementWrapper->__construct()
#1 /var/www/web/core/modules/mysql/src/Driver/Database/mysql/Insert.php(42): Drupal\Core\Database\Connection->prepareStatement()
#2 /var/www/web/modules/contrib/purge/src/Plugin/Purge/Queue/DatabaseQueue.php(60): Drupal\mysql\Driver\Database\mysql\Insert->execute()
#3 /var/www/web/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(235): Drupal\purge\Plugin\Purge\Queue\DatabaseQueue->createItem()
#4 /var/www/web/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(201): Drupal\purge\Plugin\Purge\Queue\QueueService->commitAdding()
#5 /var/www/web/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(345): Drupal\purge\Plugin\Purge\Queue\QueueService->commit()
#6 /var/www/web/modules/contrib/purge/modules/purge_drush/src/Commands/PurgeDrushCommands.php(1131): Drupal\purge\Plugin\Purge\Queue\QueueService->destruct()
#7 [internal function]: Drupal\purge_drush\Commands\PurgeDrushCommands->__destruct()

We resolved it by downgrading to previous version 3.4.0.
Site runs on the latest Drupal 9 version

alfattal’s picture

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

nicxvan’s picture

Did you downgrade to the rc or to 3.4?

nicxvan’s picture

Nevermind, the RC and 3.5 are identical, so it must be 3.4

nicxvan’s picture

Title: Queue throws error when there is a varnish purger configured. » Update to 3.5 replaces purge_drush but does not disable it.
Issue summary: View changes
Related issues: +#3394310: Plugin (drush_purge_queue_work) instance class "DrushQueueWorkProcessor" does not exist

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

japerry’s picture

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

nicxvan’s picture

Disabling it manually seemed to fix the issue though I had to add the drush processor again to my config.

baluertl’s picture

Title: Update to 3.5 replaces purge_drush but does not disable it. » Update to 3.5 replaces purge_drush but does not disable it
Assigned: Unassigned » baluertl

baluertl’s picture

baluertl’s picture

Issue summary: View changes

In an effort of trying to clean up the big picture a bit let me summarize the situation:

  1. Between the dates when versions 3.4 (Sep 14, 2022) and 3.5 (Oct 12, 2023) were released more than an entire year has passed with lots of changes (commit history). Therefore not fully clear to me why @nicxvan highlighted only those 4 commits in #13 out of the 14 in total. Maybe he is right but I still suspect all changes until getting a deeper understanding of the issue.
  2. Also, I feel unsure whether the issue reported in #9 and joined in #10 stems from the same root as the originally reported one. @pasive and @alfattal could you please test and confirm that upgrading to version 3.5, then manually disabling the purge_drush submodule (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.
  3. Do we agree that any other contrib projects (eg. varnish_purge as 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?
  4. Finally, in order to be able to tackle the issue (or issues? – as keeping the question open if we're facing the same bug) we definitely need to fixture the exact circumstances, and then compose a list of steps for reproducing the exception.

@all if you could paste here in a comment the result of the $ drush pdia command 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.

baluertl’s picture

Status: Active » Postponed (maintainer needs more info)
alfattal’s picture

@Balu Ertl In my case, I can confirm that disabling purge_drush and then, upgrade to 3.5 eliminated the error. I tried first to upgrade and then, manually disable purge_drush, but that DIDN'T eliminate the error.

Update: I started to get different errors when attempt to sync the database

PHP Fatal error:  Uncaught TypeError: Drupal\Core\Database\StatementWrapperIterator::__construct(): Argument #2 ($clientConnection) must be of type object, null given, called in /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/Connection.php on line 527 and defined in /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/StatementWrapperIterator.php:53
Stack trace:
#0 /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/Connection.php(527): Drupal\Core\Database\StatementWrapperIterator->__construct()
#1 /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/Connection.php(787): Drupal\Core\Database\Connection->prepareStatement()
#2 /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/Query/Select.php(525): Drupal\Core\Database\Connection->query()
#3 /home/ffattal/mndor/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/DatabaseQueue.php(112): Drupal\Core\Database\Query\Select->execute()
#4 /home/ffattal/mndor/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(473): Drupal\purge\Plugin\Purge\Queue\DatabaseQueue->numberOfItems()
#5 /home/ffattal/mndor/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(209): Drupal\purge\Plugin\Purge\Queue\QueueService->numberOfItems()
#6 /home/ffattal/mndor/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(345): Drupal\purge\Plugin\Purge\Queue\QueueService->commit()
#7 /home/ffattal/mndor/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}
  thrown in /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/StatementWrapperIterator.php on line 53

Fatal error: Uncaught TypeError: Drupal\Core\Database\StatementWrapperIterator::__construct(): Argument #2 ($clientConnection) must be of type object, null given, called in /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/Connection.php on line 527 and defined in /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/StatementWrapperIterator.php on line 53

TypeError: Drupal\Core\Database\StatementWrapperIterator::__construct(): Argument #2 ($clientConnection) must be of type object, null given, called in /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/Connection.php on line 527 in /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/StatementWrapperIterator.php on line 53

Call Stack:
    3.2812   70395624   1. Drupal\purge_drush\Commands\PurgeDrushCommands->__destruct() /home/ffattal/mndor/docroot/modules/contrib/purge/modules/purge_drush/src/Commands/PurgeDrushCommands.php:0
    3.2812   70395624   2. Drupal\purge\Plugin\Purge\Queue\QueueService->destruct() /home/ffattal/mndor/docroot/modules/contrib/purge/modules/purge_drush/src/Commands/PurgeDrushCommands.php:1131
    3.2812   70395624   3. Drupal\purge\Plugin\Purge\Queue\QueueService->commit($sync_stat = ???) /home/ffattal/mndor/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php:345
    3.2812   70395624   4. Drupal\purge\Plugin\Purge\Queue\QueueService->numberOfItems() /home/ffattal/mndor/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php:209
    3.2812   70395624   5. Drupal\purge\Plugin\Purge\Queue\DatabaseQueue->numberOfItems() /home/ffattal/mndor/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php:473
    3.2813   70399152   6. Drupal\Core\Database\Query\Select->execute() /home/ffattal/mndor/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/DatabaseQueue.php:112
    3.2813   70399304   7. Drupal\Core\Database\Connection->query($query = 'SELECT COUNT(*) AS "expression"\nFROM\n{purge_queue} "purge_queue"', $args = [], $options = []) /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/Query/Select.php:525
    3.2813   70399744   8. Drupal\Core\Database\Connection->prepareStatement($query = 'SELECT COUNT(*) AS "expression"\nFROM\n{purge_queue} "purge_queue"', $options = ['fetch' => 5, 'allow_delimiter_in_query' => FALSE, 'allow_square_brackets' => FALSE, 'pdo' => []], $allow_row_count = ???) /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/Connection.php:787
    3.2813   70400000   9. Drupal\Core\Database\StatementWrapperIterator->__construct($connection = class Drupal\mysql\Driver\Database\mysql\Connection { protected $target = 'default'; protected $key = 'default'; protected $logger = NULL; protected $transactionLayers = []; protected $driverClasses = ['Schema' => 'Drupal\\mysql\\Driver\\Database\\mysql\\Schema', 'Condition' => 'Drupal\\Core\\Database\\Query\\Condition', 'Select' => 'Drupal\\mysql\\Driver\\Database\\mysql\\Select', 'Upsert' => 'Drupal\\mysql\\Driver\\Database\\mysql\\Upsert', 'Truncate' => 'Drupal\\mysql\\Driver\\Database\\mysql\\Truncate', 'Update' => 'Drupal\\mysql\\Driver\\Database\\mysql\\Update', 'Merge' => 'Drupal\\mysql\\Driver\\Database\\mysql\\Merge', 'Delete' => 'Drupal\\mysql\\Driver\\Database\\mysql\\Delete', 'Insert' => 'Drupal\\mysql\\Driver\\Database\\mysql\\Insert']; protected $statementWrapperClass = 'Drupal\\Core\\Database\\StatementWrapperIterator'; protected $transactionalDDLSupport = FALSE; protected $connection = NULL; protected $connectionOptions = ['database' => 'drupal', 'username' => 'drupal', 'password' => 'drupal', 'host' => 'localhost', 'port' => '3306', 'namespace' => 'Drupal\\mysql\\Driver\\Database\\mysql', 'driver' => 'mysql', 'prefix' => '', 'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/', 'pdo' => [...], 'init_commands' => [...]]; protected $schema = class Drupal\mysql\Driver\Database\mysql\Schema { protected $connection = ...; protected $placeholder = 4; protected $defaultSchema = 'public'; protected $uniqueIdentifier = '6555187ca72bb7.24493336'; protected $mysqlStringTypes = [...] }; protected string $prefix = ''; protected array $tablePlaceholderReplacements = [0 => '"', 1 => '"']; protected $prefixes = []; protected $prefixSearch = []; protected $prefixReplace = []; protected $unprefixedTablesMap = []; protected $escapedTables = ['cache_container' => 'cache_container', 'config' => 'config', 'key_value' => 'key_value', 'cache_config' => 'cache_config', 'cache_default' => 'cache_default', 'cache_discovery' => 'cache_discovery', 'cache_bootstrap' => 'cache_bootstrap', 'cache_data' => 'cache_data', 'router' => 'router', 'path_alias' => 'path_alias', 'sessions' => 'sessions', 'users_field_data' => 'users_field_data', 'cachetags' => 'cachetags', 'webform_submission' => 'webform_submission', 'webform_submission_data' => 'webform_submission_data', 'purge_queue' => 'purge_queue', 'semaphore' => 'semaphore']; protected $escapedFields = ['' => '', 'table_schema' => '"table_schema"', 'table_name' => '"table_name"', 'collection' => '"collection"', 'name' => '"name"', 'config.name' => '"config"."name"', 'cid' => '"cid"', 'expire' => '"expire"', 'created' => '"created"', 'tags' => '"tags"', 'checksum' => '"checksum"', 'data' => '"data"', 'serialized' => '"serialized"', 'base_table.status' => '"base_table"."status"', 'base_table.path' => '"base_table"."path"', 'uid' => '"uid"', 'mail' => '"mail"', 'init' => '"init"', 'pass' => '"pass"', 'tag' => '"tag"', 'invalidations' => '"invalidations"', 'item_id' => '"item_id"', 'value' => '"value"', 'q.item_id' => '"q"."item_id"', 'q.data' => '"q"."data"']; protected $escapedAliases = ['name' => '"name"', 'config' => '"config"', 'expression' => '"expression"', 'base_table' => '"base_table"', 'cachetags' => '"cachetags"', 'item_id' => '"item_id"', 'data' => '"data"', 'q' => '"q"', 'purge_queue' => '"purge_queue"', 'key_value' => '"key_value"']; protected $rootTransactionEndCallbacks = []; protected $identifierQuotes = [0 => '"', 1 => '"']; private array ${Drupal\Core\Database\Connection}enabledEvents = []; protected $needsCleanup = FALSE; private $serverVersion = NULL }, $clientConnection = NULL, $query = 'SELECT COUNT(*) AS "expression"\nFROM\n"purge_queue" "purge_queue"', $options = [], $rowCountEnabled = FALSE) /home/ffattal/mndor/docroot/core/lib/Drupal/Core/Database/Connection.php:527
nicxvan’s picture

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

baluertl’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs work
StatusFileSize
new47.77 KB

baluertl’s picture

Status: Needs work » Needs review

I 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?

nicxvan’s picture

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

japerry’s picture

Status: Needs review » Needs work

I 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?

nicxvan’s picture

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

dotmundo’s picture


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

Can you explain what "config split" means and why this was neccessary. Thanks!!!

lykyd’s picture

Config 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

@all would you mind testing on your environments if this solves the exceptions?

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.

japerry’s picture

Anywhere we're creating a new instance of the plugin, ($this->pluginManager->createInstance) we're likely needing to wrap them:

  • IteratingServiceBaseTrait.php
  • InvalidationsService.php
  • PurgersService.php --> note the Akami patch already does this
  • QueueService.php
  • PluginTestBase.php
baluertl’s picture

baluertl’s picture

Status: Needs work » Needs review

Although @japerry said in #14:

“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 […]”

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_drush sub-module during the update process.

Steps as I tested:

  1. Get the fresh source code:
    • for you, it would be $ composer update drupal/purge
    • for me during testing it was $ composer require "drupal/purge:dev-3397227-update-to-3.5 as 3.x-dev" -W
  2. Ensure that Drupal's internal mechanisms are notified about the changes: $ drush updb OR $ drush devel:reinstall purge
  3. Try the original Drush command if it works (should! – for me at least does): $ drush p:queue-work

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

nicxvan’s picture

Thanks, does this add the new drush processor automatically? Or does this just allow the new core plugin to take over?

baluertl’s picture

As 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, akamai and purge_control offer 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.x branch I think.

@nicxvan Now tested again. Performing the steps above (and $ drush cc to 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:

diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml
index 7038ab9..d1646f8 100644
--- a/config/sync/core.extension.yml
+++ b/config/sync/core.extension.yml
@@ -44,7 +44,6 @@ module:
   path: 0
   path_alias: 0
   purge: 0
-  purge_drush: 0
   purge_processor_cron: 0
   purge_processor_lateruntime: 0
   purge_purger_http: 0
gauravjeet’s picture

Just clearing cache after deploying 3.5 to the server does resolve the issue for us. We did not disable purge_drush module.

japerry’s picture

I 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':

drush_purge_queue_add
drush_purge_queue_work
drush_purge_invalidate

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.

nicxvan’s picture

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

alfattal’s picture

I've tested the two PRs and still getting the error message when running drush cron or drush p:queue-work.

alfattal’s picture

Status: Needs review » Needs work
alfattal’s picture

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

tahiche’s picture

I'm getting the same database connection errors as pointed above:

Fatal error: Uncaught TypeError: Drupal\Core\Database\StatementWrapperIterator::__construct(): Argument #2 ($clientConnection) must b  
  e of type object, null given, called in /var/www/site/web/core/lib/Drupal/Core/Database/Connection.php on line 557 and defined in /va  
  r/www/site/web/core/lib/Drupal/Core/Database/StatementWrapperIterator.php on line 54                                                   
                                                                                                                                         
  TypeError: Drupal\Core\Database\StatementWrapperIterator::__construct(): Argument #2 ($clientConnection) must be of type object, null  
   given, called in /var/www/site/web/core/lib/Drupal/Core/Database/Connection.php on line 557 in /var/www/site/web/core/lib/Drupal/Cor  
  e/Database/StatementWrapperIterator.php on line 54 

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