How can I modify the arguments passed to a core hook? Due to a recent update of Drupal core, I'm getting the following error:


  Notice: Undefined index: taxonomy_term in
  taxonomy_field_formatter_view() (line 1601 of taxonomy.module)


Now, this is caused because the core taxonomy hook taxonomy_field_formatter_view() has an argument called $items that expects an array of values that have two elements: tid, a numeric value, and taxonomy_term which is the taxonomy term object.

In the case of my code, each array in $items is missing the taxonomy_term element.

Now a simple fix would be to hack core and simply set $item['taxonomy_term'] = taxonomy_term_load($item['tid']) if it doesn't already exist. But of course, hacking core is a no-no so I'm trying to find a way to catch the $items argument for taxonomy_field_formatter_view() before it is passed to this hook.

What's the approach here? Would defining hook_field_formatter_view() in a custom module and fixing the $items argument work? Presumably not because the core hook is going to fall over first, so I'll need to modify it before it's passed into these hooks?
Implement hook_module_implements_alter and replace taxonomy_field_formatter_view() to your function.