The docblock for Connection::query() has the return definition set to @return \Drupal\Core\Database\StatementInterface|int|null. However, there is also the statement return $this->connection->lastInsertId($sequence_name);. $this->connection is defined as @var \PDO and php.org defines the function as public PDO::lastInsertId ([ string $name = NULL ] ) : string.
The return definition should be changed to @return \Drupal\Core\Database\StatementInterface|int|string|null.
This error was flagged by the mglaman/drupal-check tool.
The entire original return section is as follows:
* @return \Drupal\Core\Database\StatementInterface|int|null
* This method will return one of the following:
* - If either $options['return'] === self::RETURN_STATEMENT, or
* $options['return'] is not set (due to self::defaultOptions()),
* returns the executed statement.
* - If $options['return'] === self::RETURN_AFFECTED,
* returns the number of rows affected by the query
* (not the number matched).
* - If $options['return'] === self::RETURN_INSERT_ID,
* returns the generated insert ID of the last query.
* - If either $options['return'] === self::RETURN_NULL, or
* an exception occurs and $options['throw_exception'] evaluates to FALSE,
* returns NULL. We will update one section to:
* - If $options['return'] === self::RETURN_INSERT_ID,
* returns the generated insert ID of the last query as a string.| Comment | File | Size | Author |
|---|---|---|---|
| #10 | 3125391-9.patch | 1.28 KB | beakerboy |
Comments
Comment #2
beakerboyComment #3
beakerboyPlease review this patch.
Comment #4
daffie commentedHi @Beakerboy: Your documention change looks good. What I am missing is that the next line is saying "This method will return one of the following". Could you add your possibility to that list. Also can you update the issue summery with the appropriate links. That way people can check what you are saying. Thanks for your the issue and the patch.
Comment #5
beakerboy@daffie, the RETURN_INSERT_ID option is already in the list so I think it’s good.
Comment #6
beakerboyComment #7
beakerboyComment #8
daffie commentedCan we add to the string "returns the generated insert ID of the last query" the words " as a string".
Comment #9
prabha1997 commentedComment #10
beakerboyClearly stating the return type of the RETURN_INSERT_ID case is a string in the docblock.
Comment #11
beakerboyComment #12
beakerboyComment #13
daffie commentedLooks good to me.
This issue is a documentation improvement.
For me it is RTBC.
Comment #14
prabha1997 commentedI apologize by mistakly added patch.
Comment #15
prabha1997 commentedComment #16
daffie commentedComment #17
alexpottCommitted and pushed b67ddac362 to 9.1.x and 9fcad9365d to 9.0.x. Thanks!
Backported to 9.0.x as a docs change.
Comment #20
alexpottDecided to go back to 8.9.x to keep the docs in sync. Makes and changes for bugfixes easier later on and is still true.
Comment #22
drummThere was some sort of race condition with the simultaneously-posted comments. 8.9.x-dev was in Drupal.org’s field cache, but the field data & revision tables had 9.0.x-dev stored.