﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
16749,Hooks alter/break array-formatted callbacks,Veraxus,,"When hooking to static methods of a class (plugin, theme, etc), there are two possible formats:

{{{array('class','method')}}} '''or''' {{{'class::method'}}}

The prior works on PHP 4+, where the latter requires PHP 5.2.3+

The problem is that any time I try to use an array-formatted callback with a WordPress hook (for maximum compatibility), PHP throws an invalid callback error for wp-includes/plugin.php.

It turns out that the array ultimately being passed to {{{call_user_func_array()}}} always has an integer {{{1}}} appended to the array... thus making the callback invalid as {{{call_user_func_array()}}} is now being sent this:

{{{ array('class','function',1) }}}

'''String-formatted callbacks work perfectly, but array-formatted callbacks are altered and therefore broken.''' This can be fixed by adding the following check to four different functions in plugin.php ({{{apply_filters()}}}, {{{apply_filters_ref_array()}}}, {{{do_action()}}}, and {{{do_action_ref_array()}}}), but I'm not sure this is the ""best"" solution.

Here's the ""corrective"" check:

{{{
if(is_array($the_['function']) && isset($the_['function'][2])){
   unset($the_['function'][2]);
}
}}}
",defect (bug),closed,normal,,General,3.1,normal,worksforme,,
