When you delete a revision, nothing is fired to tell other modules that a revision of that node has been deleted. This patch fires a _invoke_nodeapi" so that other modules will know, and can catch the event that a revision of a node has been deleted, and then take the correct action. This is needed for other modules such as 'upload.module', which keeps files for each revision. This patch also creates a watchdog entry when a revision is deleted.
I'm sure the wording of the watch dog entry, if it should be watched, _invoke vs another paramenter, etc. will be argued, but I wanted to get this up, so I can hear the arguments, and get this quared away and patched it. I think this is really important. Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | drupal-head.node-revision-deletion3.junyor.patch | 2.24 KB | junyor |
| #24 | drupal-head.node-revision-deletion2.junyor.patch | 2.18 KB | junyor |
| #23 | drupal-head.node-revision-deletion.junyor.patch | 2.11 KB | junyor |
| #18 | rev_delete.patch | 1.2 KB | killes@www.drop.org |
| #14 | revision.patch | 1.54 KB | m3avrck |
Comments
Comment #1
Souvent22 commentedGot fuzz warning, cleaned up my patch. Samething, just patches easier.
Comment #2
Souvent22 commentedChanged working for the watchdog and for the messege that reported after deletion.
Comment #3
Souvent22 commentedSome more wording issues, but i think this is ready to go.
Comment #4
m3avrck commentedBetter patch, gets rid of extraneous parentheses.
Comment #5
jvandyk commentedSome quick observations:
- move the node_load to just in front of the node_invoke_nodapi call, as it's unnecessary unless the if statement succeeds
- no need to comment that you are going to call node_invoke_nodeapi; just call it
The error about deleting the current revision seems odd. If I ask to delete the current revision, I should maybe be redirected to the node deleting page?
Comment #6
m3avrck commentedjvandyk, I'm not sure I understand your last comment about the delete part. It seemed intuitive to me how the patch worked, did you actually try it out yet? It worked as I expected it to work. I agree with your other comments though.
Comment #7
Souvent22 commentedthanks for the comments. I'd think after deleting a node, you'd go back to the revisions listing for that node.
Comment #8
killes@www.drop.org commentedThis is a lose end of the revisions patch that needs fixing. i am ok with the proposed patch. I think that Dries will object to
node_invoke_nodeapi($node, 'delete-revision');
and would maybe prefer
node_invoke_nodeapi($node, 'revision delete');
Comment #9
junyor commentedWhen I delete a revision, I get the following message:
"Deleted revision ()."
and in watchdog:
": deleted revision ()."
From a quick look at the code, it seems that the node is deleted before the messages are created.
Also, there's no 'delete-revision' in upload_nodeapi, so files associated with the deleted revision are never deleted.
Comment #10
Souvent22 commentedRe-rolled, and fixed the watchdog and message problems.
Comment #11
m3avrck commentedPatch applies cleanly and works.
However, I might suggest that the watch dog message and drupal_set_message output the revision ID too... kind of confusing when it says "deleted revision test story" kind of confusing. Perhaps something like: "deleted test story revision 8" ... that would be a much more explantory message as to what exactly just happened, same for logging purposes.
Comment #12
m3avrck commentedHere's an updated patch. Ready to go!
Comment #13
m3avrck commentedComment #14
m3avrck commentedUpdated patch for killes comments, Dries hopefully this name works for you, works for us (forgot to change it in my last patch). We need this patch in so we can fix other bugs, thanks!!
Comment #15
moshe weitzman commenteddoes the hook need to pass along the id of the version that was deleted?
Comment #16
killes@www.drop.org commentedIt needs to and does so by passing along the node object that got loaded with node_load($nid, $revision).
Haven't checked if it actually works, but should.
Comment #17
m3avrck commentedI have tested this patch and it does indeed work. Again, another patch holding up other patches!
Comment #18
killes@www.drop.org commentedHere is a patch that updates book and forum module. Tested.
Comment #19
m3avrck commentedJust to clarify, patch in comment 14 and the patch in comment 18 would *both* have to go in to fix the revision delete problem.
Comment #20
junyor commentedIt looks like m3avrck's patch was added to the patch in http://drupal.org/node/35644 when it was committed:
http://cvs.drupal.org/viewcvs/drupal/drupal/modules/node.module?r1=1.551...
Comment #21
junyor commentedAnd, unfortunately, the patch is flawed. It allows you to delete the current revision if the URL is typed in directly.
Comment #22
killes@www.drop.org commentedThat's correct but my patch for book and forum module need to be applied, too. And after that the change has to be documented.
Comment #23
junyor commentedI've patched HEAD (i.e. after m3avrck's patch was committed) to fix the problem I mentioned. node_revision_delete() will now check that the current revision isn't deleted, rather than checking that there's at least 2 revisions. I've also rolled in killes' patches for forum.module and book.module.
Comment #24
junyor commentedAnd rerolled from the root Drupal directory because I know it will make someone, somewhere, happy.
Comment #25
junyor commentedI did a fair amount of testing of the latest patch while working on http://drupal.org/node/31354. Everything seemed to work just fine.
Comment #26
killes@www.drop.org commentedI don't get how the problem mentioned in
http://drupal.org/node/31323#comment-56733
would be fixed by the last patch.
Comment #27
junyor commentedThe latest patch checks that the revision being deleted isn't the current revision:
Comment #28
killes@www.drop.org commentedAh, ok, I had assumed a permission check would be missing. Good to go, I think.
Comment #29
junyor commentedComment #30
m3avrck commentedWhat ever happened to the code in the patch I posted? http://drupal.org/files/issues/revision.patch ... that *was not* committed.
There is no: 'revision delete' in core, I think there might have been some confusion, I believe this patch needs to be updated.
Comment #31
m3avrck commentedComment #32
Souvent22 commentedOk. This is all messed up now. The priovus patch that m3 mentions need to go in before junyor's patch beuase junyors patch will not work with it. Thus the reason this issues was started, when a revisions is deleted, nothing fires to say that a revisions has been deleted. Thus, since an event is not fired, it can not be caught. Currently, the patch will be waiting for an event that never happends. Both are need, but one is needed before the other, or the two patches need to be combied. I'll try and do that. However, hopefully we're all in areement that both are need, primarily though the event firing is needed before anything about catching the event.
Comment #33
junyor commentedPlease read back through this issue, specifically at comment #20. m3avrck's patch was committed.
Comment #34
m3avrck commentedOk, did not realize that part of my patch was already committed, that was very strange and confusing :-/
This patch is good to go then!
Comment #35
m3avrck commentedWait, the patch in core has
delete revisionI thought it was to be:revision delete? Which is it? Either way, the current patch won't work with core since it is backwards.Comment #36
junyor commentedFixed.
Comment #37
m3avrck commentedLooks good!
Comment #38
m3avrck commentedComment #39
killes@www.drop.org commentedDries committed http://drupal.org/node/31323#comment-56048, I will take Junyor's patch into http://drupal.org/node/30098
Comment #40
(not verified) commented