Working on a custom module just found out that after deleting a revision there's still redundant data in the term_node table.

Comments

Alex Andrascu’s picture

Can't do a patch in the current environment but here's a lead

function _revisioning_delete_revision(&$node, $vid = NULL) {
  $node_revision = is_object($node) ? $node : node_load($node, $vid);
  module_invoke_all('revisionapi', 'pre delete', $node_revision);
  db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $node_revision->nid, $node_revision->vid);
  // delete any term association with the current revision
  db_query("DELETE FROM {term_node} WHERE nid = %d AND vid = %d", $node_revision->nid, $node_revision->vid);
  node_invoke_nodeapi($node_revision, 'delete revision');
  watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid));
}
Alex Andrascu’s picture

It seems the same goes for delete archived revisions function so:

/**
 * Delete all revisions with a vid less than the current.
 */
function revisioning_delete_archived_revisions($node) {
   db_query('DELETE FROM {term_node} WHERE nid = %d AND vid < %d', $node->nid, $node->current_revision_id);
  return db_query('DELETE FROM {node_revisions} WHERE nid = %d AND vid < %d', $node->nid, $node->current_revision_id);  
}
Alex Andrascu’s picture

Version: 6.x-3.15 » 6.x-3.x-dev

Also it seems this bug is to be found in the 7.x dev aswell

rdeboer’s picture

rdeboer’s picture

Assigned: Unassigned » rdeboer
Status: Active » Fixed

Patches of #1 and #2 applied to 6.x-3.x branch with attribution.
Thanks alex.
Rik

Alex Andrascu’s picture

Thank you !

Status: Fixed » Closed (fixed)

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