Rules and node revisions

Events happening in the community are now at Drupal community events on www.drupal.org.
chrisschaub's picture

In the drupal 6 rules code, in

rules/modules/node.rules.inc

there is this code:

class rules_data_type_node extends rules_data_type {
  function save() {
    $node = &$this->get();
    // Bug fix: Make sure we don't create another revision when we react on the
    // creation of an revision.
    unset($node->revision);
    node_save($node);
...

I'm not sure what bug this was fixing, but it does prevent rules from saving revisions when updating node fields. Is this desirable? I guess a work-around is to create another module to hook nodeapi and re-set the revision flag on presave. Just wondering if anyone else has tried to get rules to save revisions when updating content.

Comments

It's not as easy as setting

chrisschaub's picture

It's not as easy as setting the revision flag in node presave, that will cause dupe revisions which is, I'm assuming, the purpose of this bug fix in the code. So, how can I get updates to nodes to create revisions with triggered rules? Any help is greatly appreciated.

Actually, creating my own

chrisschaub's picture

Actually, creating my own "flag" in the node object/variable, and then creating a presave op in nodeapi in a custom module did the trick. This way, I can have rules create revisions and set revision log messages as needed.

Can you expand a little

bartl's picture

Can you expand a little exactly how you created your own flag, and what the nodeapi presave looks like?

I may need to do something similar, with the Flag module being so buggy in Drupal 7.

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: