diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 1571205a1a..c0cfd532a9 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -1064,12 +1064,14 @@ public function insert($table, array $options = []) { * (Optional) Name of the sequence object from which the ID should be * returned. * - * @return string + * @return string|false * The value returned by the wrapped PDO connection. * + * @internal + * * @see \PDO::lastInsertId */ - public function lastInsertId(?string $name = NULL): string { + public function lastInsertId(?string $name = NULL) { return $this->connection->lastInsertId($name); } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php index df63e13784..8fe4455474 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php @@ -80,7 +80,7 @@ public function execute() { // example, \Drupal\Core\Cache\DatabaseBackend. $this->connection->addSavepoint(); try { - $this->connection->query($stmt, [], $options); + $stmt->execute(NULL, $options); $this->connection->releaseSavepoint(); } catch (\Exception $e) { diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php index c500ad2908..9107bebdbf 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php @@ -138,9 +138,9 @@ public function testTransactionsOptionDeprecation() { * Tests the deprecation of passing a statement object to ::query. * * @group legacy - * @expectedDeprecation Passing a StatementInterface object as a $query argument to Drupal\Core\Database\Connection::query is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. Call the execute method from the StatementInterface object directly instead. See https://www.drupal.org/node/3154439 */ public function testStatementQueryDeprecation() { + $this->expectDeprecation('Passing a StatementInterface object as a $query argument to Drupal\Core\Database\Connection::query is deprecated in drupal:9.1.0 and is removed in drupal:10.0.0. Call the execute method from the StatementInterface object directly instead. See https://www.drupal.org/node/3154439'); $db = Database::getConnection(); $stmt = $db->prepareStatement('SELECT * FROM {test}', []); $this->assertNotNull($db->query($stmt));