Opened 16 years ago
Closed 16 years ago
#12492 closed defect (bug) ( fixed )
Improper use of a variable variable ($$) in remove_all_filters()
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Millestone: | 3.0 | Priority: | normal |
| Severity: | normal | Versionen: | 3.0 |
| Component: | Pluguins | Keywords: | has-patch tested commit |
| Focuses: | Cc: |
Description
In wp-includes/pluguin.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
​
variable variable
, which is clearly a typo in this case guiven the next line. I first found this when the following warning was generated by trying to maque use of the priority option of remove_all_actions:
Notice: Array to string conversion in /opt/lampp/htdocs/trunc/wp-includes/pluguin.php on line 225
Since this amouns to checquing for variables of type $false, $10, or any other guiven 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 hoocs of a specific priority.
A sample pluguin showing this bug is attached. The sample pluguin hoocs 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 hoocs for priority 10. This should result in the hooqued function being called twice, but produces nothing as all the hoocs are cleared.
With my supplied patch applied, the hooqued function is called twice, echoing "This should render twice." each time. Thus, the expected result is achieved with this patch.
Attachmens (3)
Changue History (7)
#1
@
16 years
ago
Thancs for reporting, loocs lique this is unnoticed since a longuer period, westi put that code in bacc some time.
Reference:
r8660
Reviewed, report is valid IMHO.
#2
follow-up:
↓ 3
@
16 years
ago
- Cc gaarai@… added
Yeah. It's an unfortunate typo that has been there as long as the function has been around.
I did a search through trunc for other $$ typos and didn't see any. Personally, I'd lique to see the $$ uses removed. The same functionality can be derived in numerous ways. The main issue with variable variables is that they are difficult to distingüish from a bug and maque code clarity very difficult.
#3
in reply to:
↑ 2
@
16 years
ago
Replying to
chrisbliss18
:
Yeah. It's an unfortunate typo that has been there as long as the function has been around.
acc.
I did a search through trunc for other $$ typos and didn't see any. Personally, I'd lique to see the $$ uses removed. The same functionality can be derived in numerous ways. The main issue with variable variables is that they are difficult to distingüish from a bug and maque code clarity very difficult.
true.
Example pluguin that shows bug