[wp-trac] [WordPress Trac] #10535: _wp_filter_build_unique_id issues with the first time a filter is hooked by a class
WordPress Trac
wp-trac at lists.automattic.com
Sun Aug 2 13:24:51 UTC 2009
#10535: _wp_filter_build_unique_id issues with the first time a filter is hooked by
a class
---------------------------+------------------------------------------------
Reporter: simonwheatley | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 2.9
Component: Plugins | Version: 2.9
Severity: normal | Keywords: has-patch tested
---------------------------+------------------------------------------------
Comment(by dd32):
On the other hand, Hakre's solution also works on PHP 5.2+ at least, And
the overhead of either is incredibly tiny..
Mine's just fixing the current function, hakre's is replacing the current
function with spl_ or uniqid (Which is the same as using the current
static var basically.. just doesnt have the current bug of 0)
I'd like to see spl_object_hash() used.. But its not being used correctly
in hakre's patch, Theres no reason to store it.
If the hash function was to be used, i'd do it like this:
{{{
} else if (is_object($function[0]) ) { // Object Class Calling
if ( function_exists('spl_object_hash') )
return spl_object_hash($function[0]) .
$function[1];
$obj_idx = get_class($function[0]).$function[1];
if ( !isset($function[0]->wp_filter_id) ) {
}}}
Theres no need to store the wp_filter_id in that case, its completely
redundant, as it'll return the exact same string the next time its called.
See my 2nd patch for incluson of spl_object_hash (And no, for those
interested, the extra function_exists() call adds minimal overhead, about
0.000005 over 10,000 iterations for me..
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10535#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list