1

I'd like to delete the current revision (made in error by an admin) for a list of nodes.

On a test site - I've looked into re-using core functionality in my script, reverting to a previous revision, then deleting the remaining revision. But the revert creates a new one itself.

I'd really like to set it so it's like the most recent revision never happened, and is gone entirely. Our system shows a history of node changes and I don't want it to show up there (and also don't want to hack the display to suppress these few erroneous revisions etc.)

Thanks!

5
  • node_revision_delete() would probably be the way to go
    – Clive
    Aug 13, 2013 at 11:13
  • It appears to not cater for deleting the current revision if($revision_id == $node->vid) {return FALSE;} Aug 13, 2013 at 11:18
  • Oh yeah, sorry. I think the point of revisions is to keep an accurate history of what's happened to the content, so creating a new revision when you revert makes absolute sense. I get the feeling you'd need to do some manual manipulation of the node/node_revision and field tables to accomplish what you need
    – Clive
    Aug 13, 2013 at 11:20
  • We've got a script here that we use for something similar, but it's quite mungy :-) i thought this would be a good opportunity to think of something cleaner. but sometimes it will always be messy when you are fighting the intended usage! Aug 13, 2013 at 11:26
  • Heh, love that word "mungy", it covers all manner of ills :) There might well be a cleaner solution, I think under-the-hood it's just going to do what your script does but if there's an 'official' solution I guess at least you know it's robust and tested
    – Clive
    Aug 13, 2013 at 11:29

0

Your Answer

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

Browse other questions tagged or ask your own question.