[wp-trac] [WordPress Trac] #57686: Introduce wp_trigger_error() to compliment _doing_it_wrong()
WordPress Trac
noreply at wordpress.org
Tue Sep 5 22:11:17 UTC 2023
#57686: Introduce wp_trigger_error() to compliment _doing_it_wrong()
-------------------------------------------------+-------------------------
Reporter: azaozz | Owner:
| hellofromTonya
Type: enhancement | Status: assigned
Priority: normal | Milestone: 6.4
Component: General | Version:
Severity: normal | Resolution:
Keywords: needs-dev-note has-patch has-unit- | Focuses:
tests |
-------------------------------------------------+-------------------------
Comment (by hellofromTonya):
Replying to [comment:8 flixos90]:
> Sounds reasonable to me. So for now that function would simply be
something like the following I assume?
>
> {{{#!php
> <?php
> function wp_trigger_error( $message, $error_level = E_USER_NOTICE ) {
> if ( ! WP_DEBUG ) {
> return;
> }
> trigger_error( $message, $error_level );
> }
> }}}
@flixos90 @azaozz [https://github.com/WordPress/wordpress-
develop/pull/5122/ I also created a PR]. It takes a different approach
than `_doing_it_wrong()`, as it's a wrapper around `trigger_error()`.
It's lean and not opinionated about the message itself, but rather passes
the message to the PHP native `trigger_error()`.
I did include the function name parameter to help identify what
function/method triggered the error, especially when logging at logs. That
parameter could be eliminated using similar code in Requests to get the
[class]function name:
{{{
$stack = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 2);
}}}
@azaozz also [https://github.com/WordPress/wordpress-develop/pull/5122/
created an implementation] which reuses `_doing_it_wrong()` code.
The big question:
Should `wp_trigger_error()` be a `trigger_error()` wrapper or a milder
verbiage form of `_doing_it_wrong()`?
Thoughts?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57686#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list