Not sure if this is a flag or rules scheduler issue.

I have a clean install of Drupal 7.23. I have installed the latest dev version of Flag and the latest stable version of Rules, Rules Scheduler and dependent modules CTools, entity and views, and also the latest stable version of token.

1. I created a flag called 'flag one' with full use permissions for authenticated users and administrators. This flag applied to the bundle 'Article'.

2. I created an rule component of type 'action set' called 'Unflag a node'. The flag to check for is 'flag one'. The component takes one parameter of type 'node'.

3. I created a reaction rule called 'flag article reaction rule' which reacts on the event 'After saving new content'.
The rule has a condition 'content is of type article'.
There are two actions. The first is to flag the node.
The second is to schedule component evaluation to unflag the node in + 2 minute for testing purposes.

On creating a new article the first action works correctly: flag one is set.
Also looking in workflow -> rules -> schedule a scheduled task is correctly created.

If I run cron after the time that the scheduled task is due to run, my Rules evaluation log says:

0 ms Scheduled evaluation of action set flag article, task flag node 8.
22.404 ms Evaluating the action flag_flagnode. [edit]
22.837 ms Finished evaluation of action set flag article, task flag node 8.
And the scheduled task disappears from the list of scheduled tasks.

But the flag remains set.

If I go to the components tab in rules and execute the component using the node id the rule runs correctly and the flag is unset.

I have not been able to test with the latest dev version of rules as my test site just hung on wampserver when I attempted this.

Comments

shabana.navas’s picture

Will take a look at this, but I have a feeling that this is not a flags issue as the flag gets unset when you manually execute the component.

forestgardener’s picture

OK. Thanks Shabana.

shabana.navas’s picture

For some reason flag_rules_action_info() is just not being triggering at all when executing this through cron. Trouble shooting this requires a bit more extensive research.

forestgardener’s picture

Thank's for looking into this Shabana
Best wishes
Craig

shabana.navas’s picture

Finally, figured this out! The problem is, we're not supplying the required parameters to the Rules component. If you have given it only 'node' as the parameter, then, when you add the action to 'Unflag a Node', you must give the 'User on whose behalf to flag' a data selector such as 'node:author'. You can't do something like 'site:current-user' because that parameter is not available to the component when run through Cron.

Once you give it the required parameters, it should unflag the node through Cron.

forestgardener’s picture

Hi Shabana
Thank you so much for your help with this issue. I have tested it using your solution and can confirm that yes indeed it does work.
Best wishes
Craig

forestgardener’s picture

Status: Active » Closed (works as designed)
eidoscom’s picture

Sorry for reopen but it is possible that if you have added some fields to the flag entity, you must specify value for the fields in order to work this??

Thanks!

shabana.navas’s picture

Not sure, will try and look into that.

marksmith’s picture

#8 you're right! Rules flag/unflag won't work this way if "Display checkbox on node edit form" is enabled on the flag configuration page.