You are here

function _node_save_revision in Drupal 7

Same name and namespace in other branches
  1. 6 modules/node/node.module \_node_save_revision()

Helper function to save a revision with the uid of the current user.

The resulting revision ID is available afterward in $node->vid.

Parameters

$node: A node object.

$uid: The current user's UID.

$update: (optional) An array of primary keys' field names to update.

1 call to _node_save_revision()
node_save in modules/node/node.module
Saves changes to a node or adds a new node.

File

modules/node/node.module, line 1215
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.

Code

function _node_save_revision($node, $uid, $update = NULL) {
  $temp_uid = $node->uid;
  $node->uid = $uid;
  if (isset($update)) {
    drupal_write_record('node_revision', $node, $update);
  }
  else {
    drupal_write_record('node_revision', $node);
  }

  // Have node object still show node owner's uid, not revision author's.
  $node->uid = $temp_uid;
}