Make WordPress Core

Opened 11 months ago

Last modified 5 weeks ago

#58484 reviewing enhancement

Site Health: Improve display of constants in debug data

Reported by: ramon-fincken's profile ramon fincken Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.6 Priority: normal
Severity: normal Version: 6.3
Component: Site Health Keywords: has-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

This is a follow up on #55741.

where we need to have just a single function to be called which determines the environment type.

As wp-admin/includes/class-wp-debug-data.php is already using:

$environment_type       = wp_get_environment_type();

and later on:
this happens

		// Check WP_ENVIRONMENT_TYPE.
		if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) {
			$wp_environment_type = WP_ENVIRONMENT_TYPE;
		} else {
			$wp_environment_type = __( 'Undefined' );
		}

so this is not the same as what happens at wp_get_environment_type();

So this ticket is where we remove that lines of code.

Attachments (7)

patch.58484.20230608.1.diff (702 bytes) - added by ramon fincken 11 months ago.
patch.58484.20230608.1.diff
patch.58484.20230608.2.diff (680 bytes) - added by ramon fincken 11 months ago.
patch.58484.20230608.2.diff
patch.58484.20230608.3.diff (3.0 KB) - added by ramon fincken 11 months ago.
patch.58484.20230608.3.diff
patch.58484.20231019.4.diff (2.9 KB) - added by ramon fincken 7 months ago.
patch.58484.20231019.4.diff
patch.58484.20231019.5.diff (3.1 KB) - added by ramon fincken 7 months ago.
patch.58484.20231019.5.diff
patch.58484.20231019.6.diff (4.0 KB) - added by ramon fincken 7 months ago.
patch.58484.20231019.6.diff
patch.58484.20231019.7.diff (3.9 KB) - added by ramon fincken 7 months ago.
patch.58484.20231019.7.diff

Download all attachments as: .zip

Change History (18)

@ramon fincken
11 months ago

patch.58484.20230608.1.diff

This ticket was mentioned in Slack in #core by ramonfincken. View the logs.


11 months ago

#2 @ramon fincken
11 months ago

a small update on this, checked with @SergeyBiryukov

this code is accurate meaning it is shown in the tools -> constants.

I will just show the PHP constant which does not have a need to call wp_get_environment_type()

However ... if you have defined WP_ENVIRONMENT_TYPE and it is empty this code will show "Undefined" while it is actually defined indeed.

#3 @ramon fincken
11 months ago

creating a new patch for this

@ramon fincken
11 months ago

patch.58484.20230608.2.diff

@ramon fincken
11 months ago

patch.58484.20230608.3.diff

#4 @ramon fincken
11 months ago

Added function

private static function get_define_info( $constant_name ) {

#5 @ramon fincken
7 months ago

Updated patch for latest Core version.

@ramon fincken
7 months ago

patch.58484.20231019.4.diff

@ramon fincken
7 months ago

patch.58484.20231019.5.diff

@ramon fincken
7 months ago

patch.58484.20231019.6.diff

@ramon fincken
7 months ago

patch.58484.20231019.7.diff

This ticket was mentioned in PR #5529 on WordPress/wordpress-develop by @ramon fincken.


7 months ago
#6

Trac ticket: https://core.trac.wordpress.org/ticket/58484

PR to enhance the tools section to show the actual result of defines.

#7 @SergeyBiryukov
7 months ago

  • Component changed from Bootstrap/Load to Site Health
  • Description modified (diff)
  • Milestone changed from Awaiting Review to 6.5
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing
  • Summary changed from Always use wp_get_environment_type in all sources to Site Health: Improve display of constants in debug data

#8 @ramon fincken
7 months ago

The github PR is the latest. Checked with @ocean90 .

So .. we have the changed code to reflect the actual values.
Also we needed a change for the debug values as you can define an empty string or for instance a NULL/null. Therefore we needed to rewrite the isset to key_exists.

Also some translator instructions were added.

We choose to use multi if instead of match/switch because it is more human readable.

#9 @swissspidy
3 months ago

@SergeyBiryukov Is this on your radar still for 6.5? Looks like a punt candidate given the lack of activity.

#10 @swissspidy
3 months ago

  • Milestone changed from 6.5 to 6.6
  • Type changed from defect (bug) to enhancement

Looks more like an enhancement to me, so punting.

#11 @ramon fincken
5 weeks ago

Bummer it did not make it in 6.5

Note: See TracTickets for help on using tickets.