I noticed the behavior that if I simply go in and change the URL alias for a page and hit submit, I still get a new revision in the moderation queue. The alias takes effect immediately, so moderation that revision is somewhat pointless. I actually don't know if this is behavior associated with the module or with the revisioning system in 5.x. I'd just like to hear a discussion on (1) where the "problem" really is, (2) if this has been address in 6.x, or (3) any logic that went into making it this way.

Comments

toemaz’s picture

The behaviour you describe is correct by design of this module. But as you describe the case, it is indeed a little odd a new revision is made. So, I guess the start of a solution might be to look into developing a mini module which implements the hook_submit for the node which is under revision_moderation.

In the submit stage, you may check what piece of the node really changed and act accordingly. In your specific case, compare the submitted title and body against the current revision. If there is no difference, I guess you can unset $node->revision or give it a false/0 value. The result will be that during the node_save execution, the current revision will be overwritten, instead of creating a new one.

So I guess this solves your problem by adding some new logic. I would not write this into the current revision_moderation module as this logic might be different for each specific case. Good luck and give some feedback if you have some results.

webchick’s picture

Title: If node title/body doesn't change, don't create new revision? » If node doesn't change, don't create new revision
Project: Revision Moderation » Drupal core
Version: 5.x-1.0 » 7.x-dev
Component: Code » node system

I think I would call this a core bug. revision_moderation just deals with the revision stuff provided by node.module.

To anyone who tries to fix this, however, bear in mind that more about a node can change than just its title/body. For example, files might've been added or removed, or terms changed, or...

chrisfromredfin’s picture

Assigned: Unassigned » chrisfromredfin

OK I'm going to put this on my todo list. Thanks for your detailed suggestions.

alexjarvis’s picture

subscribing

drupalnuts’s picture

We built something to detect changes, in a nodeapi call, we did a node_load on the nid (in the presave state) and serialized the results. We then took the node object from nodeapi, and serialized it, if they were the same, we made no change, if they were not, we added an entry to our audit table, might help here.

seandunaway’s picture

bump and subscribe :)

droplet’s picture

Version: 7.x-dev » 8.x-dev
Priority: Minor » Normal

maybe field module issue now ?

seandunaway’s picture

Just in case anyone else is having this issue, a workable solution:

I tried #5 but went crazy having to filter the node objects because a lot of the data is different between the referenced node in presave and the result of node_load.

One solution I found was to node_view both (don't forget to clone the referenced node, else your referenced node will get modified something nasty) into rendered output and then compare. This had the benefit or flaw of comparing only fields which were set to display. However, I ended up tossing it because my page/teaser views didn't have taxonomy terms, and also had voting results, etc. This could be a workable solution.

However, I finally caved and just utilized the diff module which I had already installed. Here it is for anyone else who rather let diff module do the heavy lifting. It's still kind of hacky, but I hope diff will someday abstract out a comparison function that takes two node objects and can return something more sensible that doesn't need to be theme'd. (There's an issue for that.) A patch to core to prevent revisions if unchanged would be ideal.

    case 'presave':
      // Prevent revisions, if node is unchanged.
      module_load_include('inc', 'diff', 'diff.pages');
      $rows = _diff_body_rows(node_load($node->nid), $node);
      $result = trim(strip_tags(theme('diff_table', NULL, $rows)));
      if ($result == 'No visible changes') {
        $node->revision = FALSE;
      }
      break;
chrisfromredfin’s picture

Assigned: chrisfromredfin » Unassigned
mitchell’s picture

Title: If node doesn't change, don't create new revision » If entity doesn't change, don't create new revision
Component: node system » entity system
Issue tags: +revision

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

hchonov’s picture

Issue summary: View changes
Status: Active » Closed (works as designed)

I don't know how this worked in D7, but in D8 HEAD a new revision will be created only if the checkbox Create new revision is checked. If you submit the form and that checkbox is checked, then I think it is the proper behavior to create a new revision. This might be used as e.g. solving some kind of caching problems.
If you are not happy with this behavior you can always change it in a hook_form_alter or in an entity builder.