[wp-trac] [WordPress Trac] #57686: Introduce wp_trigger_error() to compliment _doing_it_wrong()

WordPress Trac noreply at wordpress.org
Wed Sep 6 20:59:47 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 commit                                   |
-------------------------------------------------+-------------------------

Comment (by flixos90):

 Replying to [comment:21 hellofromTonya]:
 I agree with all your outlined examples in terms of difference in scope
 between the two functions, except I have concerns on the following (if I
 understand correctly):

 > There are many cases of strict type checks using `_doing_it_wrong()`
 which could include automatic handling and use `wp_trigger_error()`. For
 example, there are many "strict" data type checks such as for `string`
 that could handle scalars or even `null`. Rather than bailing out if not a
 string, if it's a scalar, handle it, trigger `wp_trigger_error()`, and
 keep going.

 Not sure about this one. Even when a core function is "forgiving" on
 handling other data types than the intended one, ''if'' we choose to raise
 a PHP warning or error, I'd argue that's just as much the developer doing
 it wrong as it is in other places. If a function is documented to receive
 a string and you pass an integer, you are doing it wrong. This is not to
 say by any means core should not be forgiving when it can, but my point is
 ''if'' we raise a warning in such a case, it should still be
 `_doing_it_wrong()` IMO.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57686#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list