First of all, I'm marking this as a bug because I think it's a design oversight that needs to be corrected before 4.7 is release. I'm sure it'll get changed if people disagree.
I was looking information on the revision system when I came across a comment from someone confused by the changes. In there they asked for node_example.module to be updated to demonstrate revisions. Thinking that was a good idea I started on it but got bent out of shape when I realized that the only way to handle a revision being deleted is through hook_nodeapi().
I'm proposing adding a hook_delete_revision, the attached patch adds this and modifies book.module and forums.module to use it.
Comment | File | Size | Author |
---|---|---|---|
#12 | hook_delete_revision_50627.patch | 2.02 KB | drewish |
#8 | hook_delete_revision_0.patch | 2 KB | drewish |
hook_delete_revision.patch | 2.79 KB | drewish | |
Comments
Comment #1
drewish CreditAttribution: drewish commentedthat patch no longer applies. i'll re-roll it though, i'd really like to get this in before the code freeze.
Comment #2
magico CreditAttribution: magico commentedThis should have been marked as "needs review", or else no one will ever look at it!
Comment #3
drewish CreditAttribution: drewish commentedwhoops, yeah that would have been helpful. oh well, it totally missed the code freeze.
Comment #4
magico CreditAttribution: magico commentedIt seems a simple patch to me. You could re-role it to HEAD and being important (as I think it is) it may get some attention from senior developers.
Comment #5
coreb CreditAttribution: coreb commentedMoving out of the "x.y.z" queue to a real queue.
Comment #6
coreb CreditAttribution: coreb commentedI incorrectly used the new "patch (to be ported)" status.
Comment #7
pwolanin CreditAttribution: pwolanin commentedThis should certainly be implemented - re-roll for HEAD, and I'd give it a big +1
Comment #8
drewish CreditAttribution: drewish commentedHere's a re-roll for HEAD, the book module now does everything through hook_nodeapi so I won't change it.
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedIs the intent here just to achieve better symmetry with the hook_insert/update/delete or does some module actually need this new hook as opposed to using nodeapi? if the latter, i suggest we add a hook when a need arises, and not earlier. not a big deal though.
Comment #10
drewish CreditAttribution: drewish commentedmoshe, it's both that and just making it obvious to developers how to support revisions. when i originally updated the example node module to support revisions it wasn't obvious to me why i needed to implement hook_nodeapi just for revisions. in my opinion a module should need to implement hook_nodeapi to do anything with its own nodes.
Comment #11
pwolanin CreditAttribution: pwolanin commentedpatch applies with offset, seems to work and is a rational addition.
Comment #12
drewish CreditAttribution: drewish commentedhere's a re-roll that applies cleanly.
Comment #13
ChrisKennedy CreditAttribution: ChrisKennedy commentedStill applies.
Comment #14
Dries CreditAttribution: Dries commentedI think we need to motivate this patch better. Why is this so important?
Comment #15
drewish CreditAttribution: drewish commentedDries, i don't know what more i can say that i haven't already said so i'll just summarize.
if you believe that modules should support revisions for nodes then it seems like you'd want to make that as easy as possible. it seems very counter intuitive that to correctly implement revision a module needs to implement hook_nodeapi. in my opinion a module should be able to do so by implementing hook_delete_revision rather than implementing hook_nodeapi to work with it's own nodes.
we've lived for two release without it so it's obviously not critical, but if we really care so much about having clean APIs, it would seem like we could clean up the warts in the ones we've got. if you don't think it's a worthwhile change feel free to mark it as won't fix.
Comment #16
catchI'd like to see this go in, but it no longer applies.
Comment #17
preventingchaos CreditAttribution: preventingchaos commentedThis is essential to the consistency and maturity of the API. It will eliminate any confusion when creating node modules that deal with revisions, and increased consistency will give more credibility and an increased appearance of professionalism to Drupal as a whole. Developers will no longer have to use hook_nodeapi as the workaround for this bug, resulting in code that makes a little more sense, more respect for Drupal from prospective developers, and possibly more adopters and people joining the community.
Comment #18
casey CreditAttribution: casey commentedhttp://api.drupal.org/api/function/hook_node_revision_delete/7