I am getting this error:
Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of /hsphere/local/home/...../sites/all/modules/flag/flag.inc

According to the docs for http://api.drupal.org/api/drupal/modules!system!system.api.php/function/..., the 'triggers' property is not optional.

Hence this is another contrib module that's misbehaving, and isn't something that Flag should have to fix.

But how I can know which module misused this hook?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Musicious’s picture

me too, when I go to actions.

This could be the source of other problems I am having... I hope.

dojorob76’s picture

I get the same message when going to Actions.

Musicious’s picture

I think this is messing up another action I have set to trigger based on a flagging event.

If I sort this I will report back... please do the same.

Will.

edit:

Full error message is....

Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of /var/aegir/static/thinkingskills-7.9/sites/all/modules/flag/flag.inc).

Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of /var/aegir/static/thinkingskills-7.9/sites/all/modules/flag/flag.inc).

Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of /var/aegir/static/thinkingskills-7.9/sites/all/modules/flag/flag.inc).

Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of /var/aegir/static/thinkingskills-7.9/sites/all/modules/flag/flag.inc).

Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of /var/aegir/static/thinkingskills-7.9/sites/all/modules/flag/flag.inc).

Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of /var/aegir/static/thinkingskills-7.9/sites/all/modules/flag/flag.inc).

Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of /var/aegir/static/thinkingskills-7.9/sites/all/modules/flag/flag.inc).

Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of /var/aegir/static/thinkingskills-7.9/sites/all/modules/flag/flag.inc).

Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of /var/aegir/static/thinkingskills-7.9/sites/all/modules/flag/flag.inc).

Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of /var/aegir/static/thinkingskills-7.9/sites/all/modules/flag/flag.inc).

and appears here... admin/structure/flags/actions/add/flagname

kaizerking’s picture

yes here also same

mvinas’s picture

Same problem here

mvinas’s picture

I replace the problematic line 1334 of flags.inc from:

if ($action['type'] != 'node' && !in_array('any', $action['triggers'])) {

to

if ($action['type'] != 'node' && (!isset($action['triggers']) || !in_array('any', $action['triggers']))) {

It worked for me

kaizerking’s picture

it should be flag.inc
Thanks , it worked for me too

heronog’s picture

EDITED wrong thread

blogook’s picture

What is the correct thread? because i have a similar problem.

Edit: Lol nevermind ..

larskleiner’s picture

Status: Active » Needs review
FileSize
526 bytes

Thanks mvinas, works for me too.

hubobbb’s picture

FileSize
55.03 KB

Thanks #10 larskleiner ;

your path file works sucessfully. but the problem is still have .like this :

Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Notice: Undefined index: triggers in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).
Warning: in_array() expects parameter 2 to be array, null given in flag_node->get_valid_actions() (line 1334 of D:\wamp\www\t7\sites\all\modules\flag\flag.inc).

the flag.inc is here .

Tks again .

Drunoober’s picture

Same problem here.... :(

did you figure it out?

I think this problem cripples the Flag_solve module too.

pls need help. thanks

ZetaTrooper’s picture

This worked for me for the Node Abuse actions.

However, when I try to set up an action for the Comment Abuse, I get a similar but different error:

Notice: Undefined index: triggers in flag_flag->get_valid_actions() (line 887 of ....|sites|all|modules|flag|flag.inc).

If I replace line 887: if ($action['type'] != $this->content_type && !in_array('any', $action['triggers'])) {

with: if ($action['type'] != $this->content_type && (!isset($action['triggers']) || !in_array('any', $action['triggers']))) {

The error goes away for me.

rogical’s picture

Status: Needs review » Needs work

Can we re-roll a complete patch?

joachim’s picture

+++ b/flag.inc
@@ -956,7 +956,7 @@ class flag_flag {
+      if ($action['type'] != 'node' && (!isset($action['triggers']) || !in_array('any', $action['triggers']))) {

This change doesn't look right to me.

The flag_flag class is generic to all content types. It shouldn't be assuming anything about subclasses.

The fix in 13 looks better, but as said above, needs rolling as a patch.

BeaPower’s picture

will this be committed?

joachim’s picture

The patch needs work first.

knsheely’s picture

I applied the patch from 10 and now I am getting the following notice when I try to add an action.

Notice: Undefined index: label in flag_actions_form() (line 426 of /home/fourc/public_html/profiles/idea/modules/contrib/flag/flag_actions.module).
Notice: Undefined index: label in flag_actions_form() (line 426 of /home/fourc/public_html/profiles/idea/modules/contrib/flag/flag_actions.module).
Notice: Undefined index: label in flag_actions_form() (line 426 of /home/fourc/public_html/profiles/idea/modules/contrib/flag/flag_actions.module).
Notice: Undefined index: label in flag_actions_form() (line 426 of /home/fourc/public_html/profiles/idea/modules/contrib/flag/flag_actions.module).
Notice: Undefined index: label in flag_actions_form() (line 426 of /home/fourc/public_html/profiles/idea/modules/contrib/flag/flag_actions.module).
Notice: Undefined index: label in flag_actions_form() (line 426 of /home/fourc/public_html/profiles/idea/modules/contrib/flag/flag_actions.module).

edit: When making the change from #13 the notices are gone. anyone want to roll that patch?

joachim’s picture

Please bear in mind my comment in #15.

SerKi’s picture

mm no exist in line 1334 flag.inc if ($action['type'] != 'node' && !in_array('any', $action['triggers'])) { , the problem is in line 1036 in beta, and .dev also in /includes/flag_flag.inc

SerKi’s picture

Version: 7.x-2.0-beta6 » 7.x-2.0-beta9
Assigned: Unassigned » SerKi
Status: Needs work » Patch (to be ported)
FileSize
541 bytes
joachim’s picture

Version: 7.x-2.0-beta9 » 7.x-3.x-dev
Status: Patch (to be ported) » Needs work
Issue tags: +Needs backport to D7

This is going to need to be fixed on 3.x first, then backported.

joachim’s picture

Ah, I see you've filed a 3.x patch over at #1778444: flag Notice: Undefined index: triggers flag_flag->get_valid_actions() patch. The way a bug across multiple branches is handled is that the same issue gets used, first on the newest branch and then working back.

joachim’s picture

Status: Needs work » Closed (works as designed)

According to the docs for http://api.drupal.org/api/drupal/modules!system!system.api.php/function/..., the 'triggers' property is not optional.

Hence this is another contrib module that's misbehaving, and isn't something that Flag should have to fix.

jastraat’s picture

For anyone who is checking this issue, I've added an issue in the pathauto issue queue:
http://drupal.org/node/1796920

I'm not sure that I fully agree that the trigger property is required based on the documentation though.

Dave Reid’s picture

Pathauto is fixed now in both 7.x-1.x-dev and 6.x-2.x-dev. Sorry about that.

krystlc’s picture

I got a similar error using Flag 7.x-3.2

Warning: in_array() expects parameter 2 to be array, null given in flag_flag->get_valid_actions() (line 1222 of ...sites/all/modules/flag/includes/flag/flag_flag.inc).

So I opened that file and edited that line and replaced:

if ($action['type'] != $this->entity_type && !in_array('any', $action['triggers'])) {

with:

if ($action['type'] != $this->entity_type && (!isset($action['triggers']) || !in_array('any', $action['triggers']))) {

slightly different from #21's patch (note entity_type)

so far no errors.

joachim’s picture

You should not have to make that hack.

See my comment #24 above -- if $action['triggers'] is not set, then a module somewhere is not returning the proper thing from a hook.

ofry’s picture

Category: Bug report » Support request
Issue summary: View changes
Status: Closed (works as designed) » Active

How I can found which another contrib module misused this hook_action_info?

ofry’s picture

Issue summary: View changes
joachim’s picture

Category: Support request » Bug report
Status: Active » Closed (works as designed)

Search your codebase for implementations of the hook.

jay.lee.bio’s picture

Ofry, it's definitely Pathauto (7.x-1.2) that's causing this issue. The error message disappeared after I disabled it, so try using 7.x-1.x-dev (#26, which I haven't tried yet).

marcel.jtf’s picture

Same problem here. @wwwjaylee, I do not use pathauto and still have this error.

jay.lee.bio’s picture

Dwp, then it's probably another module. You'll have to disable one by one until you find the source. Maybe it's a module you recently added, I don't know. Good luck.