Closed (won't fix)
Project:
Drupal core
Version:
8.0.x-dev
Component:
node system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Jul 2009 at 03:14 UTC
Updated:
25 Aug 2015 at 17:45 UTC
Jump to comment: Most recent
Comments
Comment #1
nancydruIt looks like the nodeapi option is very simple: In node_revision_revert_confirm_submit(), right after
node_save($node_revision), just addnode_invoke_nodeapi($node_revision, 'revert revision');.The contrib then has access to the old information and can get the current revision number from the database and update its tables.
Comment #2
dropcube commentedCurrently, modules could implement
hook_node_update($node)and check for!empty($node->revision), and then perform the required actions there. However, ahook_node_revert_revisionwould be a cleaner an more consistent API. Let's see what other says.Anyone know a real use case in contribs where this hooks would be needed ?
Comment #3
nancydruYes, that's why I posted it. In Web Links we have several fields to add to a node. This includes the URL being linked to. We support versioning of this data by keeping nid and vid. The other day I had need to revert a revision and discovered that the old data was lost. That's when I discovered that there is no good way to really get back to the old version.
I believe I would have a similar problem in Announcements and Quotes.
I will play around with your idea, but I have my doubts that everything I need is there (like the previous vid).
BTW, I assume you mean hook_update as I don't see a hook_node_update in the APIs.
Comment #4
nancydruYes, there is a field for "old_vid" that points to the one being reverted to, however, that field is also present when making a new revision. How would one tell the difference, other than by a query to see if it already existed? Can I rely on $node->op not being set on a reversion?
Comment #5
dropcube commentedI mean for 7.x, for 6.x
hook_nodeapi()right ?Comment #6
nancydruOops, sorry, I was trying to fix my 6.x version, so that's where my mind was.
Comment #7
catchThis would still be great, but it's too late for D7 since there's already a way to act on revision reverts via the API even if it's not very nice.
Comment #8
catchDowngrading all D8 criticals to major per http://drupal.org/node/45111
Comment #9
ekaterina commentedCan someone create a patch to add new $op = 'revert revison' to hook_nodeapi() for Drupal 6.x please?
Comment #10
nancydruI will have to get a newer code base for D7.
Comment #11
ekaterina commentedunfortunately I need it für D6 :-(
Also I found out, that all data loaded with the hook_load(), will be correctly reverted. But what should I do if I have many data related to one node. Should I load all data with this hook? What about performance? The hook_load() will be called often and not only when the user want to revert the revision.
Comment #12
nancydruThis issue is not about loading. However you load now shouldn't change.
Comment #13
horuskol commentedI have a second use case - I want to stop the automatic publishing of the reversion in order to force moderation of the content change by a second user.
Comment #14
nancydruhttp://drupal.org/project/revision_moderation
Comment #15
horuskol commentedI tried that module - it doesn't stop the automatic publishing when someone reverts.
Comment #16
quicksketchThis is a request for a dedicated hook for clarity, though as noted above, it's entirely unnecessary. The current hook_node_update() hook already includes $node->old_vid and $node->vid which can be used to identify a new revision. A lot of modules have already solved this problem using this approach and in my opinion, this change is unnecessary.
In any case I'm downgrading this issue so it doesn't prevent addition of new features per the new policy instituted at http://drupal.org/node/1201874.
Comment #17
nancydru