Make WordPress Core

Opened 4 months ago

Last modified 3 months ago

#63017 new defect (bug)

Compression via PHP documented and in URL but not used anymore

Reported by: zodiac1978's profile zodiac1978 Owned by:
Milestone: 6.9 Priority: normal
Severity: normal Version: 5.0
Component: Script Loader Keywords: has-patch needs-dev-note
Focuses: Cc:

Description

It looks like these three constants are not used anymore:

define( ‘COMPRESS_CSS’, true );
define( ‘COMPRESS_SCRIPTS’, true );
define( ‘ENFORCE_GZIP’, true )

In #44815 the check for the "c" parameter (for compression) in load-scripts.php and load-styles.php was removed.

But it is still used in this file:
https://github.com/WordPress/WordPress/blob/master/wp-includes/script-loader.php#L2199
and
https://github.com/WordPress/WordPress/blob/master/wp-includes/script-loader.php#L2377

And documented at the beginning of the file:
https://github.com/WordPress/WordPress/blob/master/wp-includes/script-loader.php#L8-L10

It looks like we can safely remove this or is there a reason to keep it?

Change History (10)

This ticket was mentioned in PR #8409 on WordPress/wordpress-develop by @sainathpoojary.


4 months ago
#1

  • Keywords has-patch added; needs-patch removed

Remove legacy compression constants (COMPRESS_SCRIPTS, COMPRESS_CSS, ENFORCE_GZIP) and related code.

Trac ticket: #63017

#2 @zodiac1978
4 months ago

  • Keywords needs-patch added; has-patch removed

Hi @sainathpoojary

thanks for the patch! It looks great.

I think we could modify some more of the inline docs:

* Several constants are used to manage the loading, concatenating and compression of scripts and CSS:

could maybe changed to something like:

* These constants are used to manage the loading and concatenating of scripts and CSS:

And

 * The globals $concatenate_scripts, $compress_scripts and $compress_css can be set by plugins
 * to temporarily override the above settings. Also a compression test is run once and the result is saved

could maybe changed to:

 * The global $concatenate_scripts can be set by plugins to temporarily override the above 
 * setting.

#3 @zodiac1978
4 months ago

  • Keywords changes-requested added; needs-patch removed

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


4 months ago

#5 @zodiac1978
3 months ago

  • Version set to 5.0

#44815 was from milestone 4.9.9, but in the version dropdown 4.9.9 is missing, so I chose 5.0 which was the first major version with this change.

#6 @zodiac1978
3 months ago

  • Keywords dev-feedback added

#7 @sainathpoojary
3 months ago

Hey @zodiac1978,

I’ve updated the documentation based on your suggestion. Whenever you have a moment, I’d appreciate it if you could take a look. Thank you!

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


3 months ago

#9 @zodiac1978
3 months ago

  • Focuses docs removed
  • Keywords has-patch needs-dev-note added; changes-requested dev-feedback removed

@sainathpoojary Thanks for the updated patch! Looks good to me.

In the latest devchat I asked for feedback - starting here:
https://wordpress.slack.com/archives/C02RQBWTW/p1741794112933009

@joemcgill, @desrosj and @joedolson have raised some concerns about the usage in plugins. I've checked every search result in the official directory, and this is only used in system reports / debugging info. Sometimes it is set to false if not defined, and only one or two times a very old plugin tries to set it according to its own option.

But no plugin uses PHP compression if this constant is set to true.

COMPRESS_CSS (95 matches in 44 plugins)
https://wpdirectory.net/search/01JPNFP946XW7V4MFBP1CRMCNW

COMPRESS_SCRIPTS (97 matches in 46 plugins)
https://wpdirectory.net/search/01JPNFQRT2WGMS9C2HCAHC271K

ENFORCE_GZIP (53 matches in 29 plugins)
https://wpdirectory.net/search/01JPNFRB89HF670GMJB8PWKJ95

As described in the description, core does not use this anymore intentionally since #44815, but there is a dev note missing about the deprecation of this constant.

A search for COMPRESS_CSS and ENFORCE_GZIP in core only shows two findings, one in debug data and one for the mentioned file:

https://github.com/search?q=repo%3AWordPress%2FWordPress%20COMPRESS_CSS&type=code
https://github.com/search?q=repo%3AWordPress%2FWordPress+ENFORCE_GZIP&type=code

Only COMPRESS_SCRIPTS shows more results, but only because the phrase catches "can_compress_scripts" too:
https://github.com/search?q=repo%3AWordPress%2FWordPress+COMPRESS_SCRIPTS&type=code

With quotes, it shows the same results:
https://github.com/search?q=repo%3AWordPress%2FWordPress+%27COMPRESS_SCRIPTS%27&type=code

As the component maintainer, maybe @azaozz can now decide on this research that this constant is unused and should be officially announced as deprecated. I would suggest adding a dev note to inform plugin authors about it, so they can remove it from those debug reports.

Maybe @SergeyBiryukov can also shed some light to why this wasn't deprecated at the time of the remove of the underlying code.

Additionally, we should open a new trac ticket for removing those constants from our own Health Check debug report.

#10 @SergeyBiryukov
3 months ago

  • Milestone changed from Awaiting Review to 6.9
Note: See TracTickets for help on using tickets.