Solution: Use a regular query instead of a EntityFieldQuery to load all entity revisions.
Explanation:
In the age function on entity.inc there's this comment:
Blockquote
* Note that this only affects field conditions. Property conditions always
* apply to the current revision.
So as long as you provide a property condition, you will get only the last revision id. If you query with fieldCondition, you will get the revisions, as the age method is actually querying the field revision table and not the node revision one (field_sql_storage.module):
else {
$tablename_function = '_field_sql_storage_revision_tablename';
$id_key = 'revision_id';
}
Otherwise, the entity table is queried so it will always return the entities and not the revisions.
You could do a addTag and modify the query object there but at this point the modifications will be so big that it's actually better to do a regular query instead.
Example using generic info for the entity and entity api entity_revision_load.
$entity_type = 'command';
$value = 1;
$entity_info = entity_get_info($entity_type);
$query = db_select($entity_info['revision table'], 'revision');
$query->fields('revision', array($entity_info['entity keys']['id'], $entity_info['entity keys']['revision']))
->condition('revision.' . $entity_info['entity keys']['id'], $value);
$revisions = $query
->execute()
->fetchAllAssoc($entity_info['entity keys']['revision']);
$entities = array();
foreach ($revisions as $key => $revision) {
$entities[] = entity_revision_load($entity_type, $key);
}
$query->fetchAll();
– Alexander Hripak Nov 22 '12 at 20:18$result = $result->fetchAll();
to the code above just gave me the errorCall to a member function fetchAll() on a non-object
. And it seems thatEntityFieldQuery
doesn't have a fetch function. – Georg Jähnig Nov 22 '12 at 20:55execute()
and do$result = $query->fetchAll()
– Alexander Hripak Nov 23 '12 at 0:56$query->entityCondition('entity_type', 'command')->propertyCondition('id', 1)->age(FIELD_LOAD_REVISION); $result = $query->fetchAll();
and still gotCall to undefined method...
. Maybe you're mixing it up withdb_select()
? – Georg Jähnig Nov 23 '12 at 11:46