diff --git a/modules/node/node.module b/modules/node/node.module index 636cb502239..85b9fadb7fd 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -806,16 +806,16 @@ function node_save(&$node) { //the node_revisions table query if ($node->is_new) { drupal_write_record('node', $node); - drupal_write_record('node_revisions', $node); + _node_save_revision($node, $user->uid); $op = 'insert'; } else { drupal_write_record('node', $node, 'nid'); if (!empty($node->revision)) { - drupal_write_record('node_revisions', $node); + _node_save_revision($node, $user->uid); } else { - drupal_write_record('node_revisions', $node, 'vid'); + _node_save_revision($node, $user->uid, 'vid'); $update_node = FALSE; } $op = 'update'; @@ -835,6 +835,22 @@ function node_save(&$node) { cache_clear_all(); } + +/** + * Helper function to save a revision with current user responsible for revision. + */ +function _node_save_revision($node, $uid, $update = NULL) { + $temp_uid = $node->uid; + $node->uid = $uid; + if (isset($update)) { + drupal_write_record('node_revisions', $node, $update); + } + else { + drupal_write_record('node_revisions', $node); + } + $node->uid = $temp_uid; +} + /** * Delete a node. */