NCIOCPL / cgov-digital-platform

The Cancer.gov Digital Communications Platform
GNU General Public License v2.0
11 stars 33 forks source link

Deploy fails when toggling purge module on. #2743

Closed blairlearn closed 7 months ago

blairlearn commented 4 years ago

Issue description

When deploying code to an environment which toggles the purge module, the deployment fails with a message about unmatched types in a database query call.

Fatal error: Uncaught TypeError: Argument 2 passed to Drupal\Core\Database\Driver\mysql\Connection::query() must be of the type array, null given, called in /mnt/www/html/ncigovcdint/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/DatabaseQueue.php on line 84 and defined in /mnt/www/html/ncigovcdint/docroot/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:356

ESTIMATE 1

Steps to reproduce the issue

  1. Deploy build-hotfix/v1.1.16 (April 5, ~3pm) to an environment which toggles the purge module on.

What's the expected result?

What's the actual result?

Additional details / screenshot

Executing drush pm-enable for modules defined in modules.int.enable...
[Acquia\Blt\Robo\Tasks\DrushTask] Running /var/www/html/ncigovcd.int/vendor/bin/drush @self pm-enable dblog acquia_connector shield simplesamlphp_auth cgov_saml_auth_config cgov_https_config cgov_caching_nocdn --no-interaction -v in /var/www/html/ncigovcd.int/docroot
The following module(s) will be enabled: acquia_connector, shield, simplesamlphp_auth, cgov_saml_auth_config, cgov_https_config, cgov_caching_nocdn, externalauth, seckit, acquia_purge, purge, purge_drush, purge_queuer_coretags, purge_processor_cron, purge_processor_lateruntime, purge_ui
 [info] Executing: /mnt/www/html/ncigovcdint/vendor/drush/drush/drush batch-process 21 --uri=default --root=/mnt/www/html/ncigovcdint/docroot
>  [notice] Checked translation for shield.
>  [notice] Checked translation for seckit.
>  [notice] Checked translation for purge.
>  [notice] Checked translation for acquia_purge.
>  [notice] Checked translation for externalauth.
>  [notice] Checked translation for simplesamlphp_auth.
>  [notice] Checked translation for acquia_connector.
>  [notice] Imported translation for seckit.
>  [notice] Translations imported: 3 added, 5 updated, 0 removed.
>  [notice] Message: One translation file imported. /3/ translations were added, /5/ translations 
> were updated and /0/ translations were removed.
> 
 [success] Successfully enabled: acquia_connector, shield, simplesamlphp_auth, cgov_saml_auth_config, cgov_https_config, cgov_caching_nocdn, externalauth, seckit, acquia_purge, purge, purge_drush, purge_queuer_coretags, purge_processor_cron, purge_processor_lateruntime, purge_ui
 [info] Undefined variable: values DatabaseQueue.php:84

Fatal error: Uncaught TypeError: Argument 2 passed to Drupal\Core\Database\Driver\mysql\Connection::query() must be of the type array, null given, called in /mnt/www/html/ncigovcdint/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/DatabaseQueue.php on line 84 and defined in /mnt/www/html/ncigovcdint/docroot/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php:356
Stack trace:
#0 /mnt/www/html/ncigovcdint/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/DatabaseQueue.php(84): Drupal\Core\Database\Driver\mysql\Connection->query('INSERT INTO pur...', NULL, Array)
#1 /mnt/www/html/ncigovcdint/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(246): Drupal\purge\Plugin\Purge\Queue\DatabaseQueue->createItemMultiple(Array)
#2 /mnt/www/html/ncigovcdint/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(200): Drupal\purge\Plugin\Purge\Queue\QueueService->commitAdding()
#3 /mnt/www/html/ncigovcdint/docroot/modules/contrib/purge/src/Plugin/Purge/Queue/QueueService.php(334): Drupal\ in /mnt/www/html/ncigovcdint/docroot/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php on line 356
[Acquia\Blt\Robo\Tasks\DrushTask]  Exit code 255  Time 14.725s
[error]  Could not toggle modules listed in modules.int.enable. 
[error]  Command `drupal:toggle:modules ` exited with code 1. 
[error]  Command `drupal:update ` exited with code 1. 
[error]  Command `artifact:update:drupal:all-sites ` exited with code 1. 

The error is caused by a typo in the purge module patch. Values are assigned to the variable $vals, but the variable $values is passed to the query method.

    $sql = 'INSERT INTO purge_queue (data, created) VALUES (:data, :created)';
    $opt = ['return' => Database::RETURN_INSERT_ID];
    $transaction = $this->connection->startTransaction();
    try {
      foreach ($items as $item) {
        $vals = [':data' => serialize($item), ':created' => $now];
        $ids[] = $this->connection->query($sql, $values, $opt);
     }

Related Tickets

blairlearn commented 7 months ago

Fixed in #2744