By beatrizrodrigues on
Change record status:
Draft (View all draft change records)
Project:
Introduced in branch:
9.3.x
Issue links:
Description:
So,
Before Drupal 9.3.0
The DocBlock return type in \Drupal\Core\Database\Query::execute() is displayed as @return \Drupal\Core\Database\StatementInterface|null however, in the classes that are extending it the return type is different, although, it is an abstract method and it can not have different types of return.
Example
Drupal\Core\Database\Query::execute() before the change
/**
* Runs the query against the database.
*
* @return \Drupal\Core\Database\StatementInterface|null
* A prepared statement, or NULL if the query is not valid.
*/
abstract protected function execute();Child class before the change
/**
* Executes the DELETE query.
*
* @return int
* The number of rows affected by the delete query.
*/
public function execute() {
$values = [];
if (count($this->condition)) {
$this->condition->compile($this->connection, $this);
$values = $this->condition->arguments();
}
$stmt = $this->connection->prepareStatement((string) $this, $this->queryOptions, TRUE);
try {
$stmt->execute($values, $this->queryOptions);
return $stmt->rowCount();
}
catch (\Exception $e) {
$this->connection->exceptionHandler()->handleExecutionException($e, $stmt, $values, $this->queryOptions);
}
}
After Drupal 9.3.0
As a implemented abstract class must have the same return as its parent, the function was deprecated and each class has to implement independently, with each one having the right DocBlock.
Example
Drupal\Core\Database\Query::execute() after the change
/**
* Runs the query against the database.
*
* @return \Drupal\Core\Database\StatementInterface|null
* A prepared statement, or NULL if the query is not valid.
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0.
* No replacement is provided. Just implement normally in the child class.
*
* @see https://www.drupal.org/node/3247516
*/
abstract protected function execute();
Impacts:
Module developers