Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Export from Rules UI looks like this:
{ "rules_sac_chapter_apply_create" : {
"LABEL" : "Create Local Chapter",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "php", "rules_scheduler" ],
"ON" : [ "node_insert" ],
"IF" : [
{ "node_is_of_type" : {
"node" : [ "node" ],
"type" : { "value" : { "sac_chapter_apply" : "sac_chapter_apply" } }
}
}
],
"DO" : [
{ "schedule" : {
"component" : "rules_sac_chapter_apply_send_pre_approval_email",
"date" : {
"select" : "site:current-date",
"php" : { "code" : "\/\/ Work in seconds for now\r\n\/\/ TODO: Update this to days\r\n$wait = variable_get('sac_chapter_apply_pre_approval_email_wait', 3);\r\n$value = $value + ($wait * 60);\r\nreturn $value;" }
},
"identifier" : "Send local chapter pre-approval email for application [node:nid]",
"param_application_node" : [ "node" ]
}
},
{ "schedule" : {
"component" : "rules_sac_chapter_apply_create_local_chapter",
"date" : {
"select" : "site:current-date",
"php" : { "code" : "\/\/ Work in seconds for now\r\n\/\/ TODO: Update this to days\r\n$wait = variable_get('sac_chapter_apply_approval_email_wait', 6);\r\n$value = $value + ($wait * 60);\r\nreturn $value;" }
},
"identifier" : "Create local chapter and send approval email for application [node:nid]",
"param_application_node" : [ "node" ]
}
},
{ "redirect" : { "url" : "sac-chapter-apply\/thanks\/\u003c?php echo $node-\u003enid; ?\u003e" } }
]
}
}
Export from drush fu looks like this:
$items['rules_sac_chapter_apply_create'] = entity_import('rules_config', '{ "rules_sac_chapter_apply_create" : {
"LABEL" : "Create Local Chapter",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "rules_scheduler" ],
"ON" : [ "node_insert" ],
"IF" : [
{ "node_is_of_type" : {
"node" : [ "node" ],
"type" : { "value" : { "sac_chapter_apply" : "sac_chapter_apply" } }
}
}
],
"DO" : [
{ "schedule" : {
"component" : "rules_sac_chapter_apply_send_pre_approval_email",
"date" : { "select" : "site:current-date" },
"identifier" : "Send local chapter pre-approval email for application [node:nid]",
"param_application_node" : [ "node" ]
}
},
{ "schedule" : {
"component" : "rules_sac_chapter_apply_create_local_chapter",
"date" : { "select" : "site:current-date" },
"identifier" : "Create local chapter and send approval email for application [node:nid]",
"param_application_node" : [ "node" ]
}
},
{ "redirect" : { "url" : "sac-chapter-apply\\/thanks\\/\\u003c?php echo $node-\\u003enid; ?\\u003e" } }
]
}
}');
Note the missing PHP code for setting the schedule date/time.
Comment | File | Size | Author |
---|---|---|---|
#10 | rules-fixed_cli_access-1331100-10.patch | 936 bytes | PatchRanger |
#8 | rules-1331100-8.patch | 527 bytes | Les Lim |
#3 | 1331100.3-rules-drush-export.patch | 479 bytes | mrfelton |
Comments
Comment #1
jacksinn CreditAttribution: jacksinn commentedI've narrowed down (hopefully) the issue to being related to the drush fu call. When using the Features UI recreate the php schedule rule comes across.
E.g. Features UI Recreate
vs `drush fu tf3`
Comment #2
fagoI guess that's a permission problem with running drush. I guess it should not check permissions in that case though.
Comment #3
mrfelton CreditAttribution: mrfelton commentedhis seems to do the trick.
Comment #5
mitchell CreditAttribution: mitchell commentedI didn't test this, marking it as rtbc based on #3.
Comment #6
fagomitchell, the idea behind RTBC is that someone different to the patch-author checks it.
Anyway, what I've said in #2 applies: There shouldn't be a permission check when rules are exported to code. If it is, what seems to be the case if #3 helps, then we need to fix that and remove that permission check.
Comment #7
mitchell CreditAttribution: mitchell commentedmitchell != mrfelton
fago, I apologize. I was making a pass through all the open bug reports, and this patch looked simple enough. I should've assured that it addressed #2.
Comment #8
Les LimThe patch in #3 didn't work for me, but using
drupal_is_cli()
to check the environment did:I think this satisfies fago's test in #6. Here, then, is the patch that removes the
access()
permission check. In its place is aneditAccess()
permission check.Comment #9
Les LimThis bug applied generally to any PHP evaluation in Rules, not just scheduling. Changing title.
Comment #10
PatchRanger CreditAttribution: PatchRanger commentedHere is the precisely consequent edition of the previous patch, please review.
Please keep in mind that it is a deal-breaker for #1540266: Fix broken simpletests (per #10 of that thread) - so I've changed the priority to "major".
Comment #11
Chipie CreditAttribution: Chipie commentedThe patch in #10 works for me. Thank you for sharing.
Comment #12
Chipie CreditAttribution: Chipie commentedComment #14
fagothx, committed.