Error on PHP8 during execution Database::closeConnection()

Created on 1 June 2022, over 2 years ago
Updated 31 May 2024, 7 months ago

Problem/Motivation

After execution a batch operation on PHP8 we use Database::closeConnection() that should avoid the MySql gone away error after a long batch operation. But Drupal throw an error

WD php: Error: User-supplied statement does not accept constructor       [error]
arguments in PDO->prepare() (line 544 of  ../docroot/includes/database/database.inc). Error: User-supplied statement does not accept constructor arguments in PDO->prepare() (line 544 of ../docroot/includes/database/database.inc).

Steps to reproduce

Run some batch operation and then try to call Database::closeConnection() on PHP8. We have close issue with tests https://www.drupal.org/project/drupal/issues/3200708 .

Seems that it issue reproduced before on php7.4 but now on php8 PDO library throws exception https://www.php.net/manual/en/pdo.error-handling.php.

Proposed resolution

I would suggest to apply fix that check in __destruct() method if we have DB connection that checks

  public function __destruct() {
    if (get_object_vars($this->connection) && ($this->needsCleanup)) {
        $this->nextIdDelete();
    }
  }
🐛 Bug report
Status

Needs work

Version

7.0 ⚰️

Component
Database 

Last updated 2 days ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇧🇾Belarus Andrei Haurukovich Minsk

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024