[wp-trac] [WordPress Trac] #46418: Use wp_die() instead of die() function in wordpress

WordPress Trac noreply at wordpress.org
Fri Sep 15 09:54:03 UTC 2023


#46418: Use wp_die() instead of die() function in wordpress
-----------------------------+-----------------------------
 Reporter:  immeet94         |       Owner:  (none)
     Type:  enhancement      |      Status:  reviewing
 Priority:  normal           |   Milestone:  Future Release
Component:  Administration   |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |     Focuses:
-----------------------------+-----------------------------
Changes (by SergeyBiryukov):

 * keywords:  has-patch needs-refresh => has-patch close
 * owner:  SergeyBiryukov => (none)


Comment:

 As previously noted in comment:5:ticket:58420, replacing `die()` with
 `wp_die()` everywhere does not seem to work as expected in my testing, as
 the `$message` parameter in `wp_die()` is an empty string by default, so
 it just displays an empty page without any message.

 Looking at [attachment:"46418.diff"], unless I'm missing something, the
 usage of `die()` is intentional in pretty much all of these instances, as
 the output is already handled in a different way and we only need to
 terminate the script.

 Using `wp_die()` there would cause unexpected output, additional overhead,
 or lead to "headers already sent" warnings when called after
 `wp_redirect()`. It also does not display any helpful error messages by
 itself, as the message is empty by default.

 I believe there are no plans for replacing all the instances of `die()` at
 this time. If there are instances where `wp_die()` would be particularly
 helpful, those may be better addressed on a case-by-case basis.

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


More information about the wp-trac mailing list