4

I have nodes that can be flagged with a global flag. When a node is updated I want a rule to unflag that node.

  • Rules Event: After updating existing content
  • Rules Action: Unflag a node.

    I then select the flag, "data selector" = node, "User on whose behalf to flag" = node:author (this field should be ignored because it's a global flag), "permission check" is unchecked.

When I update a node which has a global flag set, it doesn't get removed.

Did I set it up wrong? How can I debug a rule that doesn't want to fire?

4

Flag Module

"User on whose behalf to flag" will not be ignored in this case.

When a flag is global, users don't necessarily have the required permission to toggle it. Be sure that the user role is allowed to flag or unflag the flag in question.

A nodes 'published' status is a good example of a 'global flag' (though it has nothing to do with the flag module.) When published is TRUE content is visible, when FALSE it's hidden. Though the flag is global, only those with the 'publish content' permission can toggle it. The Flag module works similarly.


Rules Module

Rules has a built-in debugger that is useful at times. It can be found at admin/config/workflow/rules/settings


I generally end up falling back on dd() or dpm() though when debugging rules. Rules is an incredible module for sure, but debugging at times can be a pain.

  • interesting. Yeah, the user changing the node doesn't have permission to flag/unflag since it's an admin flag. I guess I could add the permission and just don't display the flag links for regular users. – uwe Sep 21 '12 at 4:20
  • wow, looks like there was a bug in flag rules, the "permission check" box is really a "skip permission check" box drupal.org/node/1550540. When I enable it everything works fine. Thanks for pointing me in the right direction! – uwe Sep 21 '12 at 4:24
1

Rules is great, but sometimes also tough to debug if things don't work as you'd expect. There are some typical facilities to do such debugging (further detailed below), but a Keep-It-Super-Simple technique I often use, is my BINGO-trick. A sample of such rule can be found in my answer to "Which Rules condition can be used to email a user when an admin updates their profile?". Stupid, but simple and efficient (I think).

If the above doesn't help, then there are typically 2 ways of more advanced debugging, as further detailed below.

Rules Evaluation Log

Within the Rules settings, experiment a bit with the debugging facilities that come with the rules module. At least have a look at the "Rules Evaluation Log" (to check that the Rules logic being executed, actually matches what you expect that logic to be).

Rules Action to display a value (using devel)

You may also want to (temporary) enable the Devel module, so that you can (temporary) add a Rules Action like "Display a value".

Obviously, make sure that there are no Rules Conditions that would prevent the rules Action(s) from being executed (if needed temporary remove such Rules Conditions).

More info

For way more details about these 2 variations, refer to Rules debugging, as explained in the answer to "How can I display the value of a variable inside a condition?".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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