Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By daffie on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
9.2.x
Introduced in version:
9.2.0
Issue links:
Description:
Passing a Drupal\Core\Database\StatementInterface object to Drupal\Core\Database\Connection::query()
is deprecated in Drupal 9.2 and will be enforced in Drupal 10.0. The method now only allows string values for the parameter $query
.
This is deprecated:
$db = \Drupal\Core\Database\Database::getConnection();
$stmt = $db->prepareStatement('SELECT * FROM {test}', []);
$result = $db->query($stmt);
Calling the method Drupal\Core\Database\Connection::query()
like this is fully supported:
$db = \Drupal\Core\Database\Database::getConnection();
$result = $db->query('SELECT * FROM {test}');
Impacts:
Module developers