another devin-inspired website
for some reason, node_save was timing out inside of a hook_workflow block. hook_workflow is passed the operation, old state, new state, and the node being operated on.
function custom_workflow($op, $old_state, $new_state, $node) { $new_state_array = workflow_get_state($new_state); $new_state_name = $new_state_array['state']; if ($op=="transition post") { if ($new_state_name=="Published") { $node->status=1; node_save($node); } } }
this wasn't working. when the workflow changed to Published, the page would hang and then die. it processed the node save, but the workflow never advanced. I'm not entirely sure why, but this quick fix made it work:
function custom_workflow($op, $old_state, $new_state, $node) { $new_state_array = workflow_get_state($new_state); $new_state_name = $new_state_array['state']; if ($op=="transition post") { if ($new_state_name=="Published") { $node = node_load($node->nid); //here $node->status=1; node_save($node); } } }
don't ask me why reloading the node (which was...already loaded) made it work. I just had a feeling that maybe something inside the node object hook_workflow was giving me might have been wonky. works perfectly now.
Leave a reply
You must be logged in to post a comment.