Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
On first install, I got the following notice:
Notice: Undefined index: flag_fetch_node_by_user in flag_rules_action_info() (line 380 of /.../sites/all/modules/contrib/flag/flag.rules.inc).
Notice: Undefined index: label in flag_rules_action_info() (line 381 of /.../sites/all/modules/contrib/flag/flag.rules.inc).
That looks like a legacy array index with no check for existence before referencing it. Line 380 of flag.rules.inc:
<?php
$items['flag_fetch_entity_by_user'] = $items['flag_fetch_node_by_user'];
?>
I've added a test for existence and I'm submitting a patch.
Comment | File | Size | Author |
---|---|---|---|
#3 | flag-undefined_index_flag_fetch_node_by_user-2333593-3-D7.patch | 404 bytes | caschbre |
| |||
#1 | undefined_index_notice-2333593-1.patch | 659 bytes | cleaver |
Comments
Comment #1
cleaver CreditAttribution: cleaver commentedComment #2
shabana.navas CreditAttribution: shabana.navas commentedI am not sure how that would turn up an undefined index. $items['flag_fetch_node_by_user'] is the new name of $items['flag_fetch_entity_by_user']. You should always have the 'flag_fetch_node_by_user' index. It is odd why you got an undefined index there.
Comment #3
caschbre CreditAttribution: caschbre commentedSo this has been plaguing me for a while. It's not happening 100% of the time, but after a cache clear I'll see this.
Basically what I see happening is
flag_fetch_definition()
is caching an empty value.$definitions = module_invoke_all('flag_type_info')
is not returning anything. I think this depends on what is triggering the cache clearing and / or rebuilding of the flag_type_info cache. I suspect it might be tied to the Rules module but not sure. Rules is throwing all sorts of warnings/errors because it is missing the flag_type_info definitions.So where are all of the flag_type_info implementations? In flag.flag.inc. There is a flag_hook_info() function to tell Drupal to go look in flag.flag.inc but I've run into issues before with hook_hook_info not always loading the include file promptly.
So a way to avoid this is by simply adding a module_load_include call before calling module_invoke_all. (see attached patch.)