I was just talking to klausi and Berdir, and none of us could figure out why \Drupal\Core\Database\Query\SelectInterface doesn't specify a execute() method. It makes all executions of select statements (when not using concrete classes as type hints) report warnings in IDEs.
The problem is also present in Drupal 7.
So, does anyone know why this was omitted? It doesn't seem likely that this was done by accident, but on the other hand I really have no explanation.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | DefaultTracker_php_-_drupal_-____Sites_dev_drupal8searchapi_drupal_.png | 15.9 KB | nick_vh |
| #1 | 2226501-1--SelectInterface_execute.patch | 779 bytes | drunken monkey |
Comments
Comment #1
drunken monkeySo, here would be a patch to add that method. (If the test bot complains, at least we might get an idea what's wrong with doing this / why it wasn't done before.)
Comment #2
drunken monkeySeems this change is perfectly acceptable, at least as far as the test bot is concerned. So, does anyone now why this is missing?
Comment #3
nick_vhMakes total sense to have it in the interface. I also do not know of exceptions so please enlighten us or get it in :)
Let's avoid the following :

Comment #4
nick_vhComment #5
drunken monkeyJust for the record, in case someone else wonders: I noticed some other missing interface methods, in
\Drupal\Core\Database\StatementInterface. There, only half of thefetch*()methods are defined, most notablyfetch()itself is missing.The methods are there, though, just commented out, and the interface comment actually explains exactly why that was done:
However, this isn't the case here, so we are still left to wonder. (Although, since Drupal 8 won't support "versions older than 5.2.6" anyways, maybe we can change that now, too?)
Comment #6
pwolanin commentedFor the other methods, look at: #2168241: Type hints for optional methods in StatementInterface (D8) / DatabaseStatementInterface (D7)
Comment #7
Crell commentedI believe it was left off because execute() is a method on the Query base class, which all query builders extend. In hindsight, that seems like a rather stupid reason. :-)
This is *probably* D7-backport-safe. (It only would break on a select object that doesn't implement execute(), which would already be pointless).
Comment #8
donquixote commented@Crell:
The reason why this will make problems in D7 for PHP 5.3.8 and older:
http://3v4l.org/5T5vv
http://stackoverflow.com/questions/17525620/php-fatal-error-cant-inherit...
https://bugs.php.net/bug.php?id=43200
Comment #9
Crell commentedSigh PHP...
Comment #10
donquixote commentedBtw, DatabaseStatement::execute() is already covered in the other issue #2168241: Type hints for optional methods in StatementInterface (D8) / DatabaseStatementInterface (D7) (although not exactly like here), but this other issue is doing too many things at once. So probably a good idea to get this in first, and then slice up the other issue into smaller ones.
Comment #11
catchCommitted/pushed to 8.x, thanks!
Comment #13
donquixote commentedWhat about http://3v4l.org/viggJ