Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently (D4.7, D5, D6, D7), node_delete($nid) does not remove entries matching $nid from the history table.
This does not help maintain traceability since the visited content is gone anyway, so the entries should be removed, or deletion blocked if traceability is a requirement, to avoid the possibility of erroneous links being generated by admin helper modules using that table.
A similar problem has been mentioned at #118108: Node delete does not clean up node_access table for node_access.
Comment | File | Size | Author |
---|---|---|---|
#16 | node_delete_from_history-318496-d6-16.patch | 569 bytes | Albert Volkman |
#10 | node_delete_from_history_2.patch | 927 bytes | DeeLay |
#2 | node_delete_from_history.patch | 698 bytes | DeeLay |
Comments
Comment #1
DeeLay CreditAttribution: DeeLay commentedComment #2
DeeLay CreditAttribution: DeeLay commentedAdded a simple query to node_delete to remove the corresponding entry from the history table.
Comment #3
stewsnoozesubscribe
Comment #4
stewsnoozeSeems fine to me.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedCascading deletes would be a nice thing to have. ;p
Comment #6
BerdirThe query needs to be rewritten to use db_delete().
http://drupal.org/node/310081
Comment #7
sharda_ram CreditAttribution: sharda_ram commentedsubscribe
Comment #8
taz88ny CreditAttribution: taz88ny commentedsubscribe
Comment #9
DeeLay CreditAttribution: DeeLay commentedThanks berdir, I guess I should also change the existing queries so instead of having:
db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
db_query('DELETE FROM {node_revision} WHERE nid = %d', $node->nid);
db_query('DELETE FROM {history} WHERE nid = %d', $node->nid);
we would end up with:
db_delete('node')
->condition('nid', $node->nid)
->execute();
db_delete('node_revision')
->condition('nid', $node->nid)
->execute();
db_delete('history')
->condition('nid', $node->nid)
->execute();
Comment #10
DeeLay CreditAttribution: DeeLay commentedattached new patch using db_delete
Comment #11
stewsnoozeComment #12
moshe weitzman CreditAttribution: moshe weitzman commentedWith bonus DBTNG cleanup. Thanks.
Comment #13
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #14
fgmProbably needs backport to 6.x (5.x ?), since it is a bug, though minor.
Comment #15
fgmSetting version for backport.
Comment #16
Albert Volkman CreditAttribution: Albert Volkman commentedD6 backport.
Comment #17
thiagomp CreditAttribution: thiagomp commentedWorked well on D6. I think it is fine.