EntityFieldQuery doesn't work correctly in hook_cron I am programming a new module in my Drupal 7 project. in my module hook_cron is override.

in my hook_cron function, I want to select a node type with specific filter for a cck field.

I am using EntityFieldQuery in order to run a query.

my specific content type is "order_status"

here us the first code of query.

$query-&gt;entityCondition('entity_type', 'node')
    -&gt;propertyCondition('type', array('order_status'))
    -&gt;propertyCondition('status', 1);
$result = $query-&gt;execute();
dpm($result);


this code works with no problem. it collects all nodes with "order_status" content type that are published. (status is 1)

but when I want to add a new cck filter to the query it doesn't work.

I have defined some cck fileds for my "order_status" content type.

one of them is field_order_status_cr_confirm 
type of this field is boolean (TRUE/FALSE or 1 | 0)

for adding a new filter to my above query I used this code.

-&gt;fieldCondition('field_order_status_cr_confirm','value',1,'=');


so my final query is 

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')
    -&gt;propertyCondition('type', array('order_status'))
    -&gt;propertyCondition('status', 1)
    -&gt;fieldCondition('field_order_status_cr_confirm','value',1,'=');
$result = $query-&gt;execute();
dpm($result);


but this code doesn't work. it returns nothing. also I changed value of the field_order_status_cr_confirm to 1 but it still returns no data.

Do you know what my problem is ?

here is the dpm function result for one node of "order_status" type.


Please help me.
I have also encountered this kind of issue that running EntityFieldQuery does not work sometimes in the cron job. 

It turns out that EntityFieldQuery will run access check. 

Cron job is run as anonymous user role and it cannot access to order_status node.

To work around this issue you can add tag DANGEROUS_ACCESS_CHECK_OPT_OUT to bypass node access.

Here is the example:

$query-&gt;entityCondition('entity_type', 'node')
    -&gt;propertyCondition('type', array('order_status'))
    -&gt;propertyCondition('status', 1);
    -&gt;addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
$result = $query-&gt;execute();