I have a rules event that is run via cron.
The event provides "tracking number" value.
But I can't load the node by this property using "Fetch entity by property" action because (after a lot of hours of debugging) I found out that "Fetch entity by property" respects node access permission, and my node is accessible to administrators only. And cron is run as anonymous user.

That's very disappointing and counter-intuitive (at least, to me).
Can we add "ignore access permissions" checkbox in settings of "Fetch entity by property" action? It would be helpful for rules launched by cron.
(the action uses EntityFieldQuery inside, and adding admin rights is as easy as adding "->addMetaData('account', user_load(1));" to EntityFieldQuery object.

Comments

Issue summary:View changes

fix

If you schedule the rule using Rules Scheduler instead of using a cron event, do you get the desired results? At the end of your rule, you can reschedule the rule for a relative time like +12 hours.

restyler, did you find a way around this? I'm having the same issue.

Component:Rules Core» Scheduler

This seems to be an issue with any action when using Rules Scheduler and cron. Changing component to Scheduler.

My problem was making a node un-sticky. Naturally anonymous users don't have that permission. Using “Fetch entity by ID” and “Set data value” and “Save entity” functions worked with Rules Scheduler.

mErilainen, well, it is not scheduler in my case.
It is custom rules event which is generated in our hook_cron.

In my case I try to send a node as mail to a user. The component only works when triggered from my admin account. And fails when it is run through scheduler. Tried using actions to change node-access before and after sending the email but no luck yet.

Doe anyone have a workaround?

I created custom rules event and pass restricted node to it and it works well with CRON run as anonymous user

<?php
function hook_cron() {
 
$query = new EntityFieldQuery();
 
$query->entityCondition('entity_type', 'node', '=')
    ->
entityCondition('bundle', 'article')
    ->
addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
 
$entities = $query->execute();
  if(
count($entities)) {
   
$nodes = array_keys($entities['node']);
    foreach (
$nodes as $nid) {
     
$node = node_load($nid);
     
rules_invoke_event('CUSTOM_EVENT', $node);
    }
  }
}
?>

Issue summary:View changes

ff

Similar issue here;

Content Access + Rules on a Drupal Commerce Rule.

I have to fecth all nodes pertaining to a particular taxonomy term, but the Rule only traks those available to the current user (it respects, as it was originally stated, node access permisions).

I also think it is counterintuitive: in Rules, you usually want the results to be site-wide unless you specify anything different. Fetch entity by property should bypass node access permisions, or at least specify taht it does so and let the user change this value...