The docs of SelectInterface::range()
read:
* @param $start
* The first record from the result set to return. If NULL, removes any
* range directives that are set.
The implementation is:
public function range($start = NULL, $length = NULL) {
$this->range = func_num_args() ? array('start' => $start, 'length' => $length) : array();
return $this;
}
It appears that the behavior depends on the number of arguments given, not on the value of $start. EntityFieldQuery has a similar range()
method and may supply NULL, NULL
to Select::range()
. In those cases, the query will never return any results.
My suggestion is to not depend on func_num_args()
but actually check the value of $start
when it is used.
I will supply patches in a couple of minutes. The bug also exists in Drupal 7, the code is still very similar.
I actually recommend that the handling of $start
and $length
be split, but that is more of a feature request than a bug.
Comment | File | Size | Author |
---|---|---|---|
#11 | 1806606-11.patch | 1.48 KB | daffie |
#11 | interdiff-1806606-3-11.txt | 857 bytes | daffie |
Comments
Comment #1
Jorrit CreditAttribution: Jorrit commentedTest only patch.
Comment #2
Jorrit CreditAttribution: Jorrit commentedComment #4
Jorrit CreditAttribution: Jorrit commentedThe patch with the fix.
Comment #8
daffie CreditAttribution: daffie commentedLook what I found. A bug with a fix. Only 4 years old!
I rerolled the patch. Some minor changes to clean up the test a bit.
Good find Jorrit!
@Jorrit: The patch that you made is almost RTBC for me. If you like my changes you can change the status to RTBC.
Comment #9
daffie CreditAttribution: daffie commentedIn the issue summary:
Comment #11
daffie CreditAttribution: daffie commentedMinor mistake
Comment #12
Jorrit CreditAttribution: Jorrit as a volunteer commentedLooks fine to me!
Comment #13
alexpottCommitted and pushed b9fc15d6225366e7580adf8c5fc3240dbf865632 to 8.2.x and cc9f4c1 to 8.1.x. Thanks!
So we need to open a new issue for D7 and then this one can be marked as fixed.
Comment #16
daffie CreditAttribution: daffie commentedCreated #2772109: Drupal\Core\Database\Query\Select::range() doesn't correctly implement SelectInterface for D7.