node_revision_create

Definition

node_revision_create($node)
modules/node.module, line 1018

Description

Create and return a new revision of the given node.

Code

<?php
function node_revision_create($node) {
  global $user;

  // "Revision" is the name of the field used to indicate that we have to
  // create a new revision of a node.
  if ($node->nid && $node->revision) {
    $prev = node_load(array('nid' => $node->nid));
    $node->revisions = $prev->revisions;
    unset($prev->revisions);
    $node->revisions[] = array('uid' => $user->uid, 'timestamp' => time(), 'node' => $prev, 'history' => $node->history);
  }

  return $node;
}
?>
 
 

Drupal is a registered trademark of Dries Buytaert.