- Patch #187799 by greggles et al: fixed problem with revisions being associated with the wrong user.

6.x
Dries Buytaert 2007-11-13 14:56:14 +00:00
parent 17d1527e3d
commit 8d01757e5d
1 changed files with 19 additions and 3 deletions

View File

@ -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.
*/