From 31f8459c24c4032ba3d55792f2cf15204d83e585 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 20 May 2009 16:59:01 +0000 Subject: [PATCH] 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 --- wp-includes/plugin.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php index 2f7d4004a..0588bc9ac 100644 --- a/wp-includes/plugin.php +++ b/wp-includes/plugin.php @@ -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;