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
Comment #0.0
restyler CreditAttribution: restyler commentedfix
Comment #1
spovlot CreditAttribution: spovlot commentedIf 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.
Comment #2
bpeicher CreditAttribution: bpeicher commentedrestyler, did you find a way around this? I'm having the same issue.
Comment #3
mErilainen CreditAttribution: mErilainen commentedThis seems to be an issue with any action when using Rules Scheduler and cron. Changing component to Scheduler.
Comment #4
mErilainen CreditAttribution: mErilainen commentedMy 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.
Comment #5
restyler CreditAttribution: restyler commentedmErilainen, well, it is not scheduler in my case.
It is custom rules event which is generated in our hook_cron.
Comment #6
danon1981 CreditAttribution: danon1981 commentedIn 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?
Comment #7
parisekI created custom rules event and pass restricted node to it and it works well with CRON run as anonymous user
Comment #7.0
parisekff
Comment #8
idiaz.ronceroSimilar 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...
Comment #9
Renee S CreditAttribution: Renee S commentedVery handy: https://drupal.org/project/rules_switch_user
Comment #10
TR CreditAttribution: TR commentedYes, rules_switch_user is the solution here. I don't see much community support for including that into core Rules.