Using the 7.x-3.x-dev is causing problems with rules
Flag and Un flag works ok except when having a Rule with the event:
A node has been unflagged, under "flag name"
When I try to un flag the node I get the following error message:
RulesEvaluationException: Argument flagging is missing. in RulesPlugin->setUpState() (line 648 of /Applications/MAMP/htdocs/mysite/sites/all/modules/rules/includes/rules.core.inc).
When I disable the rule involved, unflagging works fine
This happens with 7.x-3.x-dev or 7.x-2.x-dev with any of the flag fields patches
Note: Rules with: A node has been flagged, under "flag name" events work ok
Here's the rule causing the error
{ "rules_open_case_poll" : {
"LABEL" : "Open Case Poll",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "flag" ],
"ON" : [ "flag_unflagged_test" ],
"DO" : [ { "drupal_message" : { "message" : "Poll opened" } } ]
}
}
Comments
Comment #1
joachim commentedThanks for pasting the rule!
However, when I import this I get a notice 'Unknown event "flag_unflagged_test"'.
Comment #2
joachim commentedAha, got it now. The '_test' part is the machine name of the flag.
Comment #3
joachim commentedOk, so who knows how Rules gets its arguments in? Because I can't actually see that in our code.
Comment #4
joachim commented*sigh*
I hate working with Rules.
This is probably because there is no longer a flagging entity when we are unflagging. We'd need to check the workflow, and hook_flag() should be documented to this effect.
In 2.x, we had this:
Hence the flagging entity was added as a parameter when flaggings became entities (and so not in the great rename issue, ha!)
So we have two possible fixes:
A. Drop the flagging parameter.
B. Tell Rules that it's an optional parameter that isn't always there.
B seems the better fix to me but I have no idea how to do that. Any ideas?
Comment #5
joachim commented#1720148: optional variables in hook_rules_event_info().
Comment #6
joachim commentedEven simpler than marking it optional, in fact.
Could you try this patch please?
Comment #7
Orange Studio commentedSuccess
After applying the patch the error has gone away and now unflagging works as expected with rules.
Thanks for your help Joachim.
Comment #8
joachim commentedI've going to leave this a bit as technically we shouldn't pass in the flagging variable when we unflag. But #1720402: split hook_flag() and kill $op will fix that if we do that one first :)
Comment #9
joachim commentedIssue #1719942 by joachim: Fixed RulesEvaluationException when unflagging Rules event is invoked.
Committed this slightly modified patch.
Sort of a follow-on: #1720180: hook_flag_unflag() should be invoked before the flagging is deleted.