[wp-trac] [WordPress Trac] #58420: Use WP_Die instead of die

WordPress Trac noreply at wordpress.org
Mon May 29 13:12:33 UTC 2023


#58420: Use WP_Die instead of die
-----------------------------+-------------------------------
 Reporter:  rakibwordpress   |       Owner:  (none)
     Type:  enhancement      |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  General          |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:  has-patch close  |     Focuses:  coding-standards
-----------------------------+-------------------------------
Changes (by SergeyBiryukov):

 * keywords:  has-patch => has-patch close


Comment:

 Hi there, thanks for the ticket!

 For reference, the condition in question in `wp-trackback.php` was
 introduced in [7559].

 In my testing, [attachment:"58420.diff"] does not seem to work as
 expected, as the `$message` parameter in `wp_die()` is an empty string by
 default, so it just displays an empty page without any message.
 Introducing a specific message here is probably not worth it, as there are
 no valid uses cases for requesting a trackback in the `UTF-7` encoding.

 Replying to [comment:2 freewebmentor]:
 > We have to change all the wp_die; where as die; in core as per coding
 standards.
 > Also there are many files which used die; function which we have to
 change that from all the files.

 Could you clarify where you saw this suggestion? The
 [https://developer.wordpress.org/coding-standards/wordpress-coding-
 standards/php/ PHP Coding Standards] for WordPress don't seem to mention
 `die()` or `wp_die()` anywhere.

 Looking at [attachment:"58420-2.patch"], 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.

 Usig `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.

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


More information about the wp-trac mailing list