Loading current revision node How do I construct an entity condition so that it loads current revision of all nodes? This is my attempt.

$query = new EntityFieldQuery();
$result = $query-&gt;entityCondition('entity_type', 'node')
-&gt;entityCondition('bundle', 'xxxxx')  
-&gt;fieldCondition('xxx_module','tid', $tid,'=')  
-&gt;age(FIELD_LOAD_CURRENT)
-&gt;execute();


Instead of loading the current revision, it loads the published revision.
By default, EntityFieldQuery checks the currently logged-in user has the permission to access the queried entities. This is could be undesired, especially when the queried entity is not shown to the users, for example when a module just needs to get a list of entities to delete them.

To avoid EntityFieldQuery checks the currently logged-in user has the permission to access the entity, you need to use the following method:


addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT') for Drupal 7.15 or higher version
addMetaData('account', user_load(1)) for previous versions


Assuming you are using any version higher than 7.15, you code should be the following one.

query = new EntityFieldQuery();
$result = $query-&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', 'xxxxx')  
  -&gt;fieldCondition('xxx_module','tid', $tid,'=')  
  -&gt;age(FIELD_LOAD_CURRENT)
  -&gt;addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT')
-&gt;execute();


There could be a module that alter the query done from EntityFieldQuery and doesn't respect that tag; in that case, the query could still not return an entity revision that is not published.