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->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'xxxxx')
->fieldCondition('xxx_module','tid', $tid,'=')
->age(FIELD_LOAD_CURRENT)
->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT')
->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.