Opened 15 years ago
Closed 14 years ago
#19417 closed defect (bug) (fixed)
has_filter() can return 0, and remove_filter() doesn't use $accepted_args
| Reported by: | nacin | Owned by: | nacin |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Plugins | Version: | |
| Severity: | normal | Keywords: | has-patch commit early |
| Cc: | Focuses: |
Description
has_filter() returns priority, which means it can return 0. But core doesn't check for it being identical to false. We should audit all has_filter() calls and make sure 'false !==' or 'false ===' depending on what we want.
Additionally remove_filter() has an $accepted_args argument, but doesn't use it. We should eliminate it from the function definition and docs.
Attachments (2)
Change History (9)
#3
@
14 years ago
I'm refreshing the ticket now, it didn't apply cleanly -- we really should do this for has_action as well. Adding that in.
#5
@
14 years ago
So, has_filter() and has_action() only returns the priority when $function_to_check is also passed. Otherwise, if you're just checking the hook, it returns a boolean.
In core, we never use the second argument. So, there's no need for us to be careful about its use. This is nothing more than a documentation issue.
#6
@
14 years ago
In which case can we just include a doing_it_wrong() call or the like when some third-party code tries to pass something as priority zero? We're leaving a (small, but existant) hole open for people to do things that could lead to our checks in core returning an untrue result.
EDIT: Ignore the above, I just reread the code and found the short-circuit for false.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
We do currently check
false === has_filter()in wp-login.php.