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.
Comments