backdrop-contrib / flag

Flag module for Backdrop CMS
0 stars 11 forks source link

Bulk Operations (Actions) don't seem to be working. #21

Open jenlampton opened 3 years ago

jenlampton commented 3 years ago

I have a list of comments that are flagged. I have added the Flag (or unflag) comment action to my comment listing. When select this action and click "Execute" My comment does not get flagged (or unflagged) and instead I see the PHP warning:

Notice: Undefined index: flag in flag_comment_action() (line 134 of backdrop/modules/contrib/flag/includes/flag.actions.inc). 

The notice is correct, as there is no $context['flag_action']. There is however, $context['action_info'] but it does not seem to contain the values we need here.


PR: https://github.com/backdrop-contrib/flag/pull/22

jenlampton commented 3 years ago

From looking at hook_actions_info(), it appears as though Flag used configurable actions, which have been removed from core. The current recommended solutions for this are:

I think I might work on the 3rd one.

I'm attaching a PR for Flag that will check the specified entity, and if there is only one flag for the entity type, will use that flag to flag or unflag the entity. If there is more than one, it will throw a warning.