Extending EntityFieldQuery's method finishQuery doesn't work as supposed Extending EntityFieldQuery's method finishQuery with the following code causes query return nothing:

class ClientEntityFieldQuery extends EntityFieldQuery {

  public function finishQuery($select_query, $id_key = 'entity_id') {
    $select_query-&gt;leftJoin('field_data_field_date', 'o', 'client_event.eid = o.entity_id');
    $or = db_or()
      -&gt;condition('o.field_date_value', time(), '&lt;')
      -&gt;isNull('o.field_date_value');
    $select_query-&gt;condition($or);

    // Call parent method
    parent::finishQuery($select_query, $id_key);
  }
}


But when I copy the contents of finishQuery to the extended class (see below), the query works fine. So why does it not work when altering $select_query in the extended class and then calling parent::finishQuery($select_query, $id_key)?

This works:

class ClientEntityFieldQuery extends EntityFieldQuery {

  public function finishQuery($select_query, $id_key = 'entity_id') {
    $select_query-&gt;leftJoin('field_data_field_date', 'o', 'client_event.eid = o.entity_id');
      $or = db_or()
        -&gt;condition('o.field_date_value', time(), '&lt;')
        -&gt;isNull('o.field_date_value');
    $select_query-&gt;condition($or);

    // This is copypaste from EntityFieldQuery's method finishQuery
    foreach ($this-&gt;tags as $tag) {
      $select_query-&gt;addTag($tag);
    }
    foreach ($this-&gt;metaData as $key =&gt; $object) {
      $select_query-&gt;addMetaData($key, $object);
    }
    $select_query-&gt;addMetaData('entity_field_query', $this);
    if ($this-&gt;range) {
      $select_query-&gt;range($this-&gt;range['start'], $this-&gt;range['length']);
    }
    if ($this-&gt;count) {
      return $select_query-&gt;countQuery()-&gt;execute()-&gt;fetchField();
    }
    $return = array();
    foreach ($select_query-&gt;execute() as $partial_entity) {
      $bundle = isset($partial_entity-&gt;bundle) ? $partial_entity-&gt;bundle : NULL;
      $entity = entity_create_stub_entity($partial_entity-&gt;entity_type, array($partial_entity-&gt;entity_id, $partial_entity-&gt;revision_id, $bundle));
      $return[$partial_entity-&gt;entity_type][$partial_entity-&gt;$id_key] = $entity;
      $this-&gt;ordered_results[] = $partial_entity;
    }
    return $return;
  }

}
I think it's because you're not returning anything from the function.

The code for the base finishQuery() function returns at the very least an empty array; at the moment your function isn't doing that.

The fix might be as simple as changing the last line to:

return parent::finishQuery($select_query, $id_key);