[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
Wed Aug 4 20:04:46 UTC 2010
#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: reopened
Priority: normal | Milestone: 2.9
Component: Plugins | Version: 2.9
Severity: normal | Resolution:
Keywords: has-patch tested commit |
-------------------------------------+--------------------------------------
Changes (by mdawaffe):
* status: closed => reopened
* resolution: fixed =>
Comment:
The patched code only works if the filter didn't have anything attached to
it already.
Test case in PHP4 (and maybe PHP5 < 5.2)
{{{
require 'wp-load.php';
class Kill_It {
function dead( $i ) {
return 'DEAD';
}
}
$kill = new Kill_It; // or $kill =& new Kill_It; // Doesn't matter
var_dump( get_bloginfo( 'name', 'display' ) );
add_filter( 'bloginfo', array( &$kill, 'dead' ) );
var_dump( get_bloginfo( 'name', 'display' ) );
remove_filter( 'bloginfo', array( &$kill, 'dead' ) );
var_dump( get_bloginfo( 'name', 'display' ) );
}}}
Output:
{{{
string(6) "My WordPress Site"
string(4) "DEAD"
string(4) "DEAD"
}}}
Calling {{{remove_all_filters( 'bloginfo' )}}} prior to the
{{{add_filter()}}} results in:
{{{
string(6) "My WordPress Site"
string(4) "DEAD"
string(4) "My WordPress Site"
}}}
Confirming the problem is with filters already having attached callbacks.
Attached fixes.
For 3.1, we can simplify the function greatly since
{{{spl_object_hash()}}} is always available in PHP >= 5.2.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/10535#comment:11>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list