Opened 5 years ago
Last modified 8 months ago
#51230 new defect (bug)
WP_DEBUG is flagged when using the development environment type
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 5.5 |
| Component: | Site Health | Keywords: | good-first-bug has-patch |
| Focuses: | Cc: |
Description
This was a request from the comments of the New `wp_get_environment_type() function in WordPress 5.5 post from @robertreiser:
Setting the environment to development also sets WP_DEBUG, which makes sense and I had WP_DEBUG enabled anyway on my development site.
But the site health tool still shows an error regarding the use of WP_DEBUG:
Your site is set to display errors to site visitors
In case if setting the environment to development, this should no longer be shown as an error in the site health tool.
Change History (10)
#2
@
5 years ago
Thank you for the consideration of my comment on the WP Core blog and for turning it into a ticket, I really appreciate that. I just wanted to share some additional thoughts:
A WP user who modifies wp-config.php by either setting the WP_DEBUG flag or by setting the environment usually knows what they are doing and they do it on purpose. This is probably not the average WP user.
So I would argue that even if it is not exactly known how WP_DEBUG was set, it should not trigger either a warning or a recommendation in the site health tool when the environment is a development environment.
#3
@
5 years ago
The site health error is about displaying errors to site visitors. The WP_DEBUG_DISPLAY constant is set to true as a default. Setting it to false removes this error.
I do realize that in a development environment we should be encouraging the visibility of these errors for testing. We should be able to understand what this error means and its context.
All that being said, giving the message some context with wp_set_environment_type() is probably a good thing.
#4
follow-up:
↓ 6
@
18 months ago
- Keywords good-first-bug needs-patch added
Adding good-first-bug to explore a few ways to add some additional context for development sites.
This ticket was mentioned in Slack in #core by desrosj. View the logs.
18 months ago
#6
in reply to:
↑ 4
;
follow-up:
↓ 8
@
17 months ago
Replying to desrosj:
Adding
good-first-bugto explore a few ways to add some additional context fordevelopmentsites.
I believe this issue has been resolved. After examining the source code in class-wp-site-health.php, I noticed a condition that sets the status to 'recommended' rather than 'critical' in development environments:
// On development environments, set the status to recommended.
if ( $this->is_development_environment() ) {
$result['status'] = 'recommended';
}
This ticket was mentioned in PR #7178 on WordPress/wordpress-develop by @xaymup.
17 months ago
#7
- Keywords has-patch added; needs-patch removed
Fixing https://core.trac.wordpress.org/ticket/51230
Trac ticket:
#9
@
17 months ago
What is the plan with this ticket? Are we going to use a different message for dev environment?
The linked PR is for WP 5.5. Something like this is typically not backported to older version, is it?
#10
@
8 months ago
I just ran across this issue myself. Indeed it is unexpected for this test to fail in a local or development environment, but especially local. I've used this plugin code in the mean time to suppress:
<?php add_filter( 'site_status_tests', static function ( array $tests ): array { if ( in_array( wp_get_environment_type(), array( 'local', 'development' ), true ) ) { // Debug mode is expected on local and development environments. unset( $tests['direct']['debug_enabled'] ); } return $tests; } );
Because there is no way to know how the constant is defined (manually in the
wp-config.phpfile vs. set by WP Core after checking the environment type), I am of the opinion that this should still be flagged. However, I think the wording could be changed when the environment type isdevelopment, and it may be OK to change the type from critical to recommended.This is the current text:
Something like the following could be added to indicate the
developmentenvironment type is being used.