Index: workflow.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/workflow/workflow.module,v
retrieving revision 1.83
diff -u -r1.83 workflow.module
--- workflow.module	1 Jan 2009 21:09:16 -0000	1.83
+++ workflow.module	10 Feb 2009 21:57:13 -0000
@@ -394,7 +394,7 @@
       '#description' => t('A comment to put in the workflow log.'),
       '#default_value' => $comment,
       '#rows' => 2,
-    );      
+    );
   }
 }
 
@@ -455,8 +455,11 @@
       );
     }
 
+    $timestamp = NULL;
+    $comment = '';
+
     // See if scheduling information is present.
-    if ($node->_workflow_scheduled_timestamp && $node->_workflow_scheduled_sid) {
+    if (isset($node->_workflow_scheduled_timestamp) && isset($node->_workflow_scheduled_sid)) {
       // The default value should be the upcoming sid.
       $current = $node->_workflow_scheduled_sid;
       $timestamp = $node->_workflow_scheduled_timestamp;
@@ -467,7 +470,7 @@
       $comment = $form_state['values']['workflow_comment'];
     }
 
-    workflow_node_form($form, $form_state, $name, $name, $current, $choices, $timestamp, $comment);
+    workflow_node_form($form, $form_state, '', '', $current, $choices, $timestamp, $comment);
   }
 }
 
@@ -481,7 +484,7 @@
  *   A comment for the node's workflow history.
  * @param $force
  *   If set to TRUE, workflow permissions will be ignored.
- * 
+ *
  * @return int
  *   ID of new state.
  */
@@ -708,7 +711,11 @@
  *   The ID of the current state.
  */
 function workflow_node_current_state($node) {
-  $sid = db_result(db_query('SELECT sid FROM {workflow_node} WHERE nid = %d', $node->nid));
+  $sid = FALSE;
+
+  if (!empty($node->nid)) {
+    $sid = db_result(db_query('SELECT sid FROM {workflow_node} WHERE nid = %d', $node->nid));
+  }
 
   if (!$sid) {
     // No current state. Use creation state.
@@ -984,7 +991,7 @@
 function workflow_create($name) {
   $workflow = array(
     'name' => $name,
-    'options' => serialize(array('comment_log_node' => 1, 'comment_log_tab' => 1)), 
+    'options' => serialize(array('comment_log_node' => 1, 'comment_log_tab' => 1)),
   );
   drupal_write_record('workflows', $workflow);
   workflow_state_save(array(
@@ -1335,7 +1342,7 @@
 
 /**
  * Get a list of roles.
- * 
+ *
  * @return
  *   Array of role names keyed by role ID, including the 'author' role.
  */
@@ -1357,7 +1364,7 @@
 function workflow_cron() {
   $clear_cache = FALSE;
 
-  // If the time now is greater than the time to execute a 
+  // If the time now is greater than the time to execute a
   // transition, do it.
   $nodes = db_query('SELECT * FROM {workflow_scheduled_transition} s WHERE s.scheduled > 0 AND s.scheduled < %d', time());
 
@@ -1393,7 +1400,7 @@
  */
 function workflow_action_info_alter(&$info) {
   foreach (array_keys($info) as $key) {
-    // Modify each action's hooks declaration, changing it to say 
+    // Modify each action's hooks declaration, changing it to say
     // that the action supports any hook.
     $info[$key]['hooks'] = 'any';
   }
@@ -1434,7 +1441,7 @@
 
 /**
  * Implementation of hook_menu_alter().
- * 
+ *
  * Work around loss of menu local task inheritance in Drupal 6.2.
  */
 function workflow_menu_alter(&$callbacks) {
