1

I noticed that every time a node is updated, a timestamp column in node_revisions table is also updated for this node. I would like to change this behavior for "forum" content type and disable updating of the revisions table when forum node is edited. I don't use any modules that impact revisions. How do I achieve it (probably via my own custom module?)

[Edit]

The suggested duplicate solution ("How to disable the revision feature completely?" ) is quite a big thing. I don't want to disable revisions functionality so deeply, only in particular "forum" node type case and only prevent timestamp change, nothing else. The reason I need this is that the advanced forum module sorts topics by revision timestamp. There is a question how to change this behavior, but there is no answer, so it may be difficult and I also tried to figure it out myself but was lost - this module uses views handlers etc in code, hard to change anything.

I will try maybe to write a hook mymodule_node_save or mymodule_node_insert which is called after the revision table update (as visible in node_save function) and then just reverse this timestamp column back to node creation timestamp.

If it doesn't work then I'll try to deal with the node_save overwriting.

2
  • possible duplicate of How to disable the revision feature completely?
    – Letharion
    Aug 13, 2013 at 14:10
  • Yeah, I was thinking that the above solution drastically changes how Drupal does things by default. If you want to call a hook that runs after the revision update in node_save, I suggest calling hook_node_save, because hook_node_insert only runs when the node is newly created, not updated. :-) That should do it for you... of course, writing in the forum module queue to discuss improving the sorting functionality there is probably a good idea too! Aug 13, 2013 at 17:55

2 Answers 2

1

@camcam, have in mind that even when you are not using revisions (keeping separate node revisions for each update you make to your node content), the revisions table will still always have one record in the node_revisions table associated for each record in the node table that it keeps track of.

On the other hand, if you have enabled revisioning, you will have multiple entries in your node_revision table associated with each node, corresponding, not just to the current revision, but all past revisions too.

My suggestion is to make sure you really want to mess with that functionality before you go ahead and do anything - because what you're seeing is actually standard behavior. :-)

If you look at the code in node_save, you can see that a revision is created or updated in each instance of a node_save() call.

If this really doesn't work for you, I'd suggest using the hook_form() function to edit which function is called when your specific node content type is saved, and you can choose not to call the standard node_save() function (this should only be done if really necessary). The api documentation, along with some code samples in the comments, can be found here: https://api.drupal.org/api/drupal/modules!node!node.api.php/function/hook_form/7.

0

I believe you'll have to change the submit handler on the form in question. I had a quick look and don't see anywhere else, but you want to override the standard node_save() function.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.