Make sure filter IDs are unique. Props bkrausz, hakre. fixes #8723

git-svn-id: http://svn.automattic.com/wordpress/trunk@11409 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-05-20 16:59:01 +00:00
parent 4e1feb62af
commit 31f8459c24
1 changed files with 5 additions and 6 deletions

View File

@ -665,13 +665,14 @@ function _wp_call_all_hook($args) {
*
* @global array $wp_filter Storage for all of the filters and actions
* @param string $tag Used in counting how many hooks were applied
* @param string|array $function Used for creating unique id
* @param callback $function Used for creating unique id
* @param int|bool $priority Used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise.
* @param string $type filter or action
* @return string Unique ID for usage as array key
* @return string|bool Unique ID for usage as array key or false if $priority === false and $function is an object reference, and it does not already have a uniqe id.
*/
function _wp_filter_build_unique_id($tag, $function, $priority) {
global $wp_filter;
static $filter_id_count = 0;
// If function then just skip all of the tests and not overwrite the following.
if ( is_string($function) )
@ -682,10 +683,8 @@ function _wp_filter_build_unique_id($tag, $function, $priority) {
if ( !isset($function[0]->wp_filter_id) ) {
if ( false === $priority )
return false;
$count = isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0;
$function[0]->wp_filter_id = $count;
$obj_idx .= $count;
unset($count);
$obj_idx .= isset($wp_filter[$tag][$priority]) ? count((array)$wp_filter[$tag][$priority]) : 0;
$function[0]->wp_filter_id = $filter_id_count++;
} else
$obj_idx .= $function[0]->wp_filter_id;
return $obj_idx;