When using additional flags with harmony, the flag_access_multiple hook will return a null value from harmony and will cause flag to error. Obviously this also needs to be fixed with harmony, but it doesn't hurt to patch it here.

The error occurs on line line 568 in flag_flag.inc I fixed it by adding if ($module_access) before the foreach loop.

The error in question:
Warning: Invalid argument supplied for foreach() in flag_flag->access_multiple() (line 568 of /flag/includes/flag/flag_flag.inc).

Comments

joachim’s picture

Title: 'flag_access_multiple' Hook Error with Harmony » hook_flag_access_multiple() should mention what to return when there is no data
Version: 7.x-3.5 » 7.x-3.x-dev
Component: Flag core » Documentation

> the flag_access_multiple hook will return a null value from harmony and will cause flag to error. Obviously this also needs to be fixed with harmony, but it doesn't hurt to patch it here.

Yup, it's up to harmony to fix it. If a module, such as Flag, exposes a hook for other modules to implement, it's up to those modules to do so properly. Flag shouldn't have to babysit what the implementing modules return.

However, I'll grant you that the docs for the hook could do to mention that an empty array should be returned rather than NULL when the hook implementation has nothing to say:

 * @return
 *   An array whose keys are the object IDs and values are booleans indicating
 *   access.

I'll take a patch for that :)

joachim’s picture

Status: Active » Fixed

Fixed.

  • joachim committed a923578 on 7.x-3.x
    Issue #2379839 by joachim: Fixed hook_flag_access_multiple() docs...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.