Skip to content

Commit

Permalink
Site Health: Adjust display of the DB_COLLATE and `WP_ENVIRONMENT_T…
Browse files Browse the repository at this point in the history
…YPE` constants.

Includes: 
* Simplifying the logic and bringing some consistency to how the values are checked and displayed.
* Correcting the debug value for `DB_COLLATE`. This should be the actual contents of the constant, and empty if it is indeed empty, as the debug data that's copied and shared should represent the raw value, and does not need to be in a user-readable format.

Follow-up to [45782], [52021], [54239], [59147].

Props Clorith, SergeyBiryukov.
See #58265.

git-svn-id: https://develop.svn.wordpress.org/trunk@59155 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Oct 1, 2024
1 parent 957b4e5 commit 522a909
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/wp-admin/includes/class-wp-debug-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -1332,19 +1332,21 @@ public static function get_wp_constants(): array {
}

// Check WP_ENVIRONMENT_TYPE.
if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) {
$wp_environment_type = WP_ENVIRONMENT_TYPE;
if ( defined( 'WP_ENVIRONMENT_TYPE' ) ) {
$wp_environment_type = WP_ENVIRONMENT_TYPE ? WP_ENVIRONMENT_TYPE : __( 'Empty value' );
$wp_environment_type_debug = WP_ENVIRONMENT_TYPE;
} else {
$wp_environment_type = __( 'Undefined' );
$wp_environment_type = __( 'Undefined' );
$wp_environment_type_debug = 'undefined';
}

// Check DB_COLLATE.
if ( defined( 'DB_COLLATE' ) && DB_COLLATE ) {
$wp_db_collate = DB_COLLATE;
} elseif ( defined( 'DB_COLLATE' ) && empty( DB_COLLATE ) ) {
$wp_db_collate = __( 'Defined, but empty' );
if ( defined( 'DB_COLLATE' ) ) {
$db_collate = DB_COLLATE ? DB_COLLATE : __( 'Empty value' );
$db_collate_debug = DB_COLLATE;
} else {
$wp_db_collate = __( 'Undefined' );
$db_collate = __( 'Undefined' );
$db_collate_debug = 'undefined';
}

$fields = array(
Expand Down Expand Up @@ -1422,7 +1424,7 @@ public static function get_wp_constants(): array {
'WP_ENVIRONMENT_TYPE' => array(
'label' => 'WP_ENVIRONMENT_TYPE',
'value' => $wp_environment_type,
'debug' => $wp_environment_type,
'debug' => $wp_environment_type_debug,
),
'WP_DEVELOPMENT_MODE' => array(
'label' => 'WP_DEVELOPMENT_MODE',
Expand All @@ -1436,8 +1438,8 @@ public static function get_wp_constants(): array {
),
'DB_COLLATE' => array(
'label' => 'DB_COLLATE',
'value' => $wp_db_collate,
'debug' => $wp_db_collate,
'value' => $db_collate,
'debug' => $db_collate_debug,
),
);

Expand Down

0 comments on commit 522a909

Please sign in to comment.