Closed (works as designed)
Project:
Flag
Version:
6.x-1.1
Component:
Flag core
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 May 2009 at 03:08 UTC
Updated:
14 Sep 2009 at 20:43 UTC
The documentation for flag::flag says:
* @param $skip_permission_check
* Flag the item even if the $account user don't have permission to do so.
However, before even checking this flag value, the code bails out with:
if (!$account->uid) {
// Anonymous users can't flag with this system. For now.
//
// @todo This is legacy code. $flag->user_access() should handle this.
// This will also make it posible to have flags that do support anonymous
// users.
return FALSE;
}
Use case: flag a node for cron processing, unflag during cron. Since cron is being ran as the anonymous user, unflagging fails.
Comments
Comment #1
quicksketchThis isn't a bug, since Flag really, really can't store an anonymous flag. If an anonymous user were to be the flagging user, Flag would not know how to store that data in the database. For the use-case you've stated (running during cron), you should user_load() the $account you want to have flag the content, then pass that in as the $account parameter.
Comment #2
mitchell commentedWhat do you mean flag for cron processing? How would you use this?
You may want to look at #271582: Allow anonymous users to flag content as well.
Comment #3
mitchell commentedTag
Comment #4
yhager commented> What do you mean flag for cron processing? How would you use this?
I'd like to do post processing on nodes being saved on the system. Due to the nature of the application, processing on node_save() was ruled out as it was too slow (nodes are created on a batch from feedapi, and it slows it down significantly).
The flag I use is a global flag, so the UID in {flag_content} is always 0.
I've come up with the following solution, which uses a user_load(1), which I dislike in general. Let me know what you think of this.
Comment #5
quicksketchYep, that's what I would suggest until anonymous flagging support is officially added in #271582: Allow anonymous users to flag content, then this problem will be fixed as well.
Comment #6
mitchell commentedI'm not sure if this is 100% relevant, but perhaps #423834: Integrate Job Queue with Rules could help.
Comment #7
quicksketchMarking by design.