Whenever my feeds import finds a new version of an existing piece of content, it creates a new revision of this node instead of overwriting data.

Normally the new revision becomes the "current" one right away. I would like the currently displayed revision however to remain the same, and let a moderator decide later if the new one should be published.

  • 1
    Have you tried using Workbench Moderation, Workflow, or any of the modules that do the same thing?
    – mpdonadio
    Apr 16, 2012 at 13:50
  • I haven't. I initially assumed that because I create the node in code, they didn't apply. Perhaps that's not the case.
    – Letharion
    Apr 16, 2012 at 14:13

2 Answers 2


A standard Drupal install does not allow you to create a "Pending" revision. You have two options:

  1. Programatically create a new revision but programatically revert back to the original revision (which creates an even newer revision, but it has the original content)
  2. (Recommended) Use Workbench Moderation, Revisioning or Workflow which are well thought-out solutions for version control and/or access control.

For option 1: You can add this code as a new Rule or use it in a new module

  // Programatically load the existing revision and save it
  // Taken from http://api.drupal.org/api/drupal/modules!node!node.module/function/node_save/7
  // Load the revision
  $original_revision = node_load($nid);
  $original_revision->revision = 1;
  $original_revision->log = t('Copy of the revision from %date.', array('%date' => format_date($original_revision->revision_timestamp)));

  $new_revision = node_load($nid);
  // Make any changes to the new revision here...
  $new_revision->revision = 1;
  $new_revision->log = t('Summarize your changes here');

  // Save the new revision first

  // Save the original one again so that it is still the current revision

  watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid));
  drupal_set_message(t('@type %title was saved with a new revision, but reverting to original revision from %revision-date.', array('@type' => node_type_get_name($node_revision), '%title' => $node_revision->title, '%revision-date' => format_date($node_revision->revision_timestamp))));
  drupal_goto('node/' . $node_revision->nid . '/revisions');

For option 2: I would recommend Workbench over Revisioning or Workflow, but each is different depending on your needs. Workbench is kind of the successor to Revisioning, and Workflow is a lot more than just version control, so it may or may not be a good fit for your needs.

Here's a quick breakdown on the differences between Workbench and Workflow.

  • The first option would be great, but how do I make the revert?
    – Letharion
    Apr 16, 2012 at 15:18
  • Added the code for option 1, but really option 2 is probably your best bet because it adds functionality for handling which version is current, instead of just duplicating the original over and over again Apr 16, 2012 at 16:50
  • the link is broken Dec 17, 2015 at 2:54
  • Where to write in hook_form_alter ?
    – KTM
    Aug 26, 2016 at 12:06
  • link fixed. @IcecreamJelly, try hook_node_update. Aug 26, 2016 at 16:48

This is a guess, but I would give the Workbench Moderation sub-module in the Workbench module a shot. I have found this much easier to set up than Workflow.

The fact that you are creating nodes in code shouldn't matter, as long as the node_save() runs as a user with the proper settings for the content type (the moderation states are handled with the node API). This may mean, though, that you need to do some session shenanigans to get things done as the proper user when Feeds runs.

  • 2
    +1 workbench moderation is a superb module I've been using it for quite a while now
    – Clive
    Apr 16, 2012 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.