Here's my symptoms.

In flag_abuse I'm trying to alter the default flag options. I can put a dsm() at the end of my hook implementation and I'm returned the expected alterations. But if I put:

drupal_alter('flag_options', $this, $options);
dsm($options);

I am presented with the original $options array, completely unaltered.

Following is the code that should work:

/**
 * Implementation of hook_flag_options_alter().
 */
function flag_abuse_flag_options_alter($flag, &$options) {
  // $options['events'][] = 'reset'; //only able to do this after the flag_events patch...
  $options += array(
    'reset_short' => 'Reset flags',
    'reset_long' => 'Reset all flags on this '. $flag->content_type,
    'reset_message' => 'Flags reset.',
  );
  $options['roles'] += array('reset' => array(DRUPAL_AUTHENTICATED_RID));
}
CommentFileSizeAuthor
#3 flag_options_alter_fix.patch590 bytesquicksketch

Comments

quicksketch’s picture

Hmm, looks like we may have a problem with our call to drupal_alter(). Only the first parameter is ever passed by reference. If we swap the parameters and make it drupal_alter('flag_options', $options, $flag) it should work.

sirkitree’s picture

There is also the option of using the special case: __drupal_alter_by_ref
@see http://api.drupal.org/api/function/drupal_alter/6

quicksketch’s picture

Status: Active » Fixed
StatusFileSize
new590 bytes

Most of the time the pass-by-reference array is the first parameter, so I've swapped the arguments to match most other APIs in Drupal. Thanks for the report and research sirkitree!

quicksketch’s picture

Version: 6.x-2.x-dev » 6.x-2.0-beta1

Status: Fixed » Closed (fixed)

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