I have several sites with workbench moderation (version 7.x-3.0), and after installing and configured the module node_revision delete, I noticed that I was deleting hundreds of revisions when updating the nodes.
So I noticed several problems around the work that was committed previously in the following issue Implements hook_workbench_moderation_transition

List of problems:
1. It's a wrong hook that is being used, node_revision_delete_workbench_moderation_transition is not the proper hook to perform this action, because the table workbench_moderation_node_history is not yet populated and I cannot retrieve the current and published revisions from the node object at this point.
Please see the issue Current revision from workbench moderation is not excluded, and with this hook I cannot have this patch working correctly.

If the maintainers of this module wants to keep this behavior that I disagree, the following code could be applied instead as a possible solution:

function hook_node_update($node) {
  // Invoke your callback function AFTER the node is updated.
  drupal_register_shutdown_function('_hook_the_function_to_call', $node);
}

function _hook_the_function_to_call($node) {
  // Getting the config variable.
  $node_revision_delete_track = variable_get('node_revision_delete_track', array());

  if (isset($node_revision_delete_track[$node->type])) {
    $deleted_revisions = _node_revision_delete_do_delete($node->nid, $node_revision_delete_track[$node->type]['minimum_revisions_to_keep']);

    if (!empty($deleted_revisions->count)) {
      drupal_set_message(t('Deleted @total revisions.', array('@total' => $deleted_revisions->count)));
    }
  }
}

2. If I have hundreds of revisions to be deleted, this can cause unexpected impacts to the user and to the node that is being updated. So the user has to wait for all revisions to be deleted after saving a node, and as well we can have errors when saving drafts or published revisions as reported here Error saving a draft, and it's because of what I mentioned previously on point 1.

3. This introduces an ambiguity, because if I have a website that uses workbench moderation it will delete revisions when updating nodes, but on the other hand, if I don't use workbench moderation it does not delete revisions when updating nodes. Doesn't make sense for me.

4. There is no configuration on the backend that allows me to turn off this behavior.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nelsongrin created an issue. See original summary.

nelsongrin’s picture

So my proposal is very simple, is to remove this problematic hook and allow to be only CRON to delete revisions as it should be.

nelsongrin’s picture

Status: Active » Needs review
piotrsmykaj’s picture

Status: Needs review » Reviewed & tested by the community

I do agree, this hook should not be used here and I do agree with explanations by @nelsongrin. The patch #3 works well.

  • adriancid committed 89a6344 on 7.x-3.x authored by nelsongrin
    Issue #3134728 by nelsongrin, piotrsmykaj, adriancid: Updating nodes...
adriancid’s picture

Status: Reviewed & tested by the community » Fixed

Thanks

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.