[wp-trac] [WordPress Trac] #46813: wp_die() may generate doing_it_wrong notices, confusing other WP error handling
WordPress Trac
noreply at wordpress.org
Sun Apr 14 11:26:38 UTC 2019
#46813: wp_die() may generate doing_it_wrong notices, confusing other WP error
handling
-------------------------------------------------+---------------------
Reporter: ohiosierra | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.2
Component: Bootstrap/Load | Version: trunk
Severity: normal | Resolution:
Keywords: servehappy has-patch has-unit-tests | Focuses:
-------------------------------------------------+---------------------
Comment (by tmdesigned):
Well I'm really okay with either. I've uploaded the original approach with
a matching unit test.
So as a summary for others, there are two approaches here to prevent the
last PHP error from being polluted with _doing_it_wrong notices that may
be triggered within {{{wp_die()}}}.
**46813.4** works by using the {{{doing_it_wrong_trigger_error}}} filter
to stop {{{_doing_it_wrong}}} from fully executing.
**46813.5** works by directly checking for the {{{$wp_query}}} global
inside of {{{wp_die()}}} before calling the query functions.
In either case, I would appreciate a second pair of eyes on the related
unit test. I will note again that it's my first for WordPress core.
(There are some slight differences between the tests for the 2 approaches,
with the tests for 46813.4 being more complicated as it had to disable the
{{{_doing_it_wrong}}} handling built into the unit tests. It works well
enough, but on failure produces an ''error'' instead of a ''failure''
which I imagine is more ideal.)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46813#comment:15>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list