When adding a feed using add_feed (wp-includes/rewrite.php) you can not replace the callback function with a one with a different name, as this will try to remove a callback that doesn't exist, thus remove_action fails. Adding a $remove_function to the function variables and checking for its presence and removing the correct callback function fixes this.
buggy version
function add_feed($feedname, $function) {
global $wp_rewrite;
if (!in_array($feedname, $wp_rewrite->feeds)) { //override the file if it is
$wp_rewrite->feeds[] = $feedname;
}
$hook = 'do_feed_' . $feedname;
remove_action($hook, $function, 10, 1);
add_action($hook, $function, 10, 1);
return $hook;
}
fixed version
function add_feed($feedname, $function, $remove_function="") {
global $wp_rewrite;
if (!in_array($feedname, $wp_rewrite->feeds)) { //override the file if it is
$wp_rewrite->feeds[] = $feedname;
}
$hook = 'do_feed_' . $feedname;
if($remove_function != "") remove_action($hook, $remove_function, 10, 1);
else remove_action($hook, $function, 10, 1);
add_action($hook, $function, 10, 1);
return $hook;
}