Opened 17 months ago
Closed 14 months ago
#58420 closed enhancement (duplicate)
Use WP_Die instead of die
Reported by: | rakibwordpress | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 6.3 |
Component: | General | Keywords: | has-patch |
Focuses: | coding-standards | Cc: |
Description
In src/wp-trackback.php file the function on line 66 use die() where we can use wp_die() as this show more user friendly error message.
Attachments (2)
Change History (9)
This ticket was mentioned in PR #4517 on WordPress/wordpress-develop by @rakibwordpress.
17 months ago
#1
- Keywords has-patch added
#2
follow-up:
↓ 5
@
17 months ago
Hi @rakibwordpress, Welcome back to WordPress Trac!
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.
speedyprem commented on PR #4517:
17 months ago
#3
@rakibwebdev 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.
@ankitmaru commented on PR #4517:
17 months ago
#4
@speedyprem Yes, I agree with you.
#5
in reply to:
↑ 2
@
17 months ago
- Keywords close added
Hi there, thanks for the ticket!
For reference, the condition in question in wp-trackback.php
was introduced in [7559].
In my testing, 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 posting a trackback in the UTF-7
encoding.
Replying to 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 PHP Coding Standards for WordPress don't seem to mention die()
or wp_die()
anywhere.
Looking at 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.
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.
#6
@
16 months ago
I wonder where/why we use
// Don't load directly.
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
(mostly used, having a comment)
if ( ! defined( 'ABSPATH' ) ) {
die();
}
(not having a comment), like seen in \wp-admin\link-parse-opml.php, \wp-admin\site-health-info.php
or even
if ( ! defined( 'ABSPATH' ) ) {
exit();
}
like seen in \wp-includes\rss-functions.php
Do we want to unify them? I opened a ticket: #58987
Trac ticket: