Opened 9 years ago
Closed 6 years ago
#34183 closed defect (bug) (fixed)
Add context to `doing_it_wrong_trigger_error` filter
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
At present the doing_it_wrong_trigger_error
filter is a boolean on-off switch for _doing_it_wrong()
's trigger_error()
call.
The doing_it_wrong_run
action is available to catch all of the _doing_it_wrong()
s but there's no easy way to disable a single _doing_it_wrong
notice.
The following code can be used to conditionally disable it:
add_action( 'doing_it_wrong_run', '_abc_maybe_cancel_notice', 10, 2 ); function _abc_maybe_cancel_notice( $function, $message ) { if ( WP_DEBUG && 'specific _doing_it_wrong message' == $message ) { add_filter( 'doing_it_wrong_trigger_error', '_abc_cancel_notice' ); } } function _abc_cancel_notice() { remove_filter( 'doing_it_wrong_trigger_error', '_abc_cancel_notice' ); return false; }
It would be far simpler if the same context were passed to both filters.
I'm on the fence here - Either you're interested in the notices, or you're not.. but at the same time, sometimes you're using a library (such as HyperDB) which triggers the notices and you just want silence again..
Any thoughts?
Attachments (2)
Change History (11)
#2
@
9 years ago
- Keywords 2nd-opinion has-patch added; needs-patch removed
In the above patch, I added all the three arguments to the function. It's probably most usable that way, at least we need $function
and $message
I think. We could remove $version
if it is too specific, but I'd say it can be in there.
In addition to that, I'm proposing to do the same change for the deprecated_argument_trigger_error
filter. Whenever we agree on which parameters exactly should be added to the filter (whether it's like in the patch above or not), we can simply apply the change to the other filter as well.
#3
@
8 years ago
- Keywords 2nd-opinion removed
- Milestone changed from Awaiting Review to Future Release
Adding all parameters seems legit to me. @flixos90 Do you want to work on a refresh here?
#4
@
8 years ago
- Owner set to flixos90
- Status changed from new to assigned
@swissspidy Oh I forgot about this one. Sure, will do.
#5
@
8 years ago
34183.2.diff is the updated patch (docs adjustments only).
I agree, it would provide much more flexibility. Passing just the function name would be a huge improvement already.