Quantcast
Viewing all articles
Browse latest Browse all 291491

EntityFieldQuery::$orderedResults is always empty

According to the documentation executing an EntityFieldQuery should fill an array called EntityFieldQuery::$orderedResults:

After executing the query, $this->orderedResults will contain a list of the same stub entities in the order returned by the query. This is only relevant if there are multiple entity types in the returned value and a field ordering was requested. In every other case, the returned value contains everything necessary for processing.

see https://api.drupal.org/api/drupal/includes!entity.inc/function/EntityFieldQuery%3A%3Aexecute/7
see https://api.drupal.org/api/drupal/includes!entity.inc/property/EntityFieldQuery%3A%3AorderedResults/7

But this array is always empty caused by simply typo. Function finishQuery stores the results in $this->ordered_results instead of $this->orderedResults:

<?php
class EntityFieldQuery {

  public
$orderedResults = array();

  function
finishQuery($select_query, $id_key = 'entity_id') {
    foreach (
$select_query->execute() as $partial_entity) {
     
$this->ordered_results[] = $partial_entity;
    }
  }
}
?>

I attached a patch that fixes the typo and ensures fresh orderedResults on each execution.

AttachmentSizeStatusTest resultOperations
orderedResults.patch830 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 40,046 pass(es).View details | Re-test

Viewing all articles
Browse latest Browse all 291491

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>