[wp-trac] [WordPress Trac] #12492: Improper use of a variable variable ($$) in remove_all_filters()
WordPress Trac
wp-trac at lists.automattic.com
Wed Mar 3 00:30:48 UTC 2010
#12492: Improper use of a variable variable ($$) in remove_all_filters()
--------------------------+-------------------------------------------------
Reporter: chrisbliss18 | Owner: westi
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.0
Component: Plugins | Version: 3.0
Severity: normal | Keywords: has-patch tested commit
--------------------------+-------------------------------------------------
In wp-includes/plugin.php's remove_all_filters function are the following
lines of code:
{{{
if( false !== $priority && isset($$wp_filter[$tag][$priority]) )
unset($wp_filter[$tag][$priority]);
}}}
The $$ is a [http://www.php.net/manual/en/language.variables.variable.php
variable variable], which is clearly a typo in this case given the next
line. I first found this when the following warning was generated by
trying to make use of the priority option of remove_all_actions:
Notice: Array to string conversion in /opt/lampp/htdocs/trunk/wp-
includes/plugin.php on line 225
Since this amounts to checking for variables of type $false, $10, or any
other given argument, which won't exist, the second argument is currently
useless. Thus, until the supplied patch is implemented, it won't be
possible to use remove_all_filters or remove_all_actions to remove all
hooks of a specific priority.
A sample plugin showing this bug is attached. The sample plugin hooks the
same function to the template_redirect action three times with priorities
of default, 20, and 30. It then uses the remove_all_actions function
(which simply calls remove_all_filters) to remove all template_redirect
hooks for priority 10. This should result in the hooked function being
called twice, but produces nothing as all the hooks are cleared.
With my supplied patch applied, the hooked function is called twice,
echoing "This should render twice." each time. Thus, the expected result
is achieved with this patch.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12492>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list