I've set up rules to defer publishing on node save to a specified date. The rules component successfully runs at the later date and sends an email alert to the node author to let them know that their node has been published. But the rules component does not succeed in actually publishing the node.
I am pretty confident that the component works OK, because if I execute it directly, providing the node id as the content identifier (using direct input mode), it works as expected, i.e. sends the email alert and publishes the node.
The issue arises only when the component is run by cron. My best guess - drawing on this stackoverflow Q&A - is that this may be connected to cron, on D7, always being run as the anonymous user.
I'm puzzled, however. There are several D7 discussions around of how to use Rules to defer publishing, e.g. this Drupal Answers Q&A or this drupal.org comment (about using this approach on D7 - it is a comment on a D6 page). The fact that neither of these mention any issue with the anonymous user, make me wonder if I'm getting something very basic wrong and/or have an unusual configuration. It would seem odd that Rules Scheduler couldn't, more or less out of the box, achieve deferred publishing.
I've looked at the 'Configure access for using this component with a permission' option for the component and tried out various settings of that without fixing the issue. I'm not clear I understand the function of this option and haven't found any documentation / Q&As so far that have helped.
For reference, the rules component (that works when executed manually using the node id, but send the email without publishing the node when triggered by cron) is (when exported) as follows:
{ "rules_publish_content" : {
"LABEL" : "Delayed publish action",
"PLUGIN" : "rule set",
"REQUIRES" : [ "rules" ],
"USES VARIABLES" : { "delayed_node" : { "label" : "Delayed node", "type" : "node" } },
"RULES" : [
{ "RULE" : {
"IF" : [
{ "node_is_of_type" : {
"node" : [ "delayed-node" ],
"type" : { "value" : { "news" : "news" } }
}
},
{ "NOT node_is_published" : { "node" : [ "delayed-node" ] } }
],
"DO" : [
{ "mail" : {
"to" : [ "delayed-node:author:mail" ],
"subject" : "Your item, \u0022[delayed-node:title]\u0022, has been published.",
"message" : "Your item, \u0022[delayed-node:title]\u0022, has been published.\r\n\r\n[delayed-node:url]\r\n\r\nnode id: [delayed-node:nid]\r\n\r\nnode date: [delayed-node:field-date]\r\n\r\nnode status: [delayed-node:status]\r\n",
"language" : [ "" ]
}
},
{ "node_publish" : { "node" : [ "delayed-node" ] } }
],
"LABEL" : "Delayed publishing: publish and alert"
}
}
]
}
}
Configure access for using this component with a permission
is a way of adding an access check to a component, which you do NOT want to do in this case, so make sure you have unset everything related to that option (the option is used when you want to restrict component execution to admins, etc.) I would next try removing the "node is not published" conditional and the mail action (leave just the conditional for node is of type and the publish action) and see if that works. – Patrick Kenny May 24 '13 at 12:20