Commit ce376ec299 for wordpress.org
commit ce376ec299346f68b9bda6b143939ce9289ffd1e
Author: westonruter <westonruter@git.wordpress.org>
Date: Sun Oct 18 04:18:49 2026 +0000
Script Loader: Remove the unused compression test.
The compression test ran on admin screens until it stored its result in the `can_compress_scripts` option, but that result has had no effect since PHP compression was removed from `load-scripts.php` and `load-styles.php` in r43580, and the last code reading it was removed in r64485. The test also failed with a 400 error when `admin_url()` was filtered to add a query string, as translation plugins do, since it appended a second `?` to the AJAX URL. Users without `manage_options` were sent the test on every admin page, since the AJAX handler rejected their requests and the option was never set. Rather than fixing the URL, the test is removed.
The `compression_test()` and `wp_ajax_wp_compression_test()` functions are deprecated as no-ops so that existing callers do not cause fatal errors, and the `wp-compression-test` AJAX action is no longer registered. On single sites, the option is already deleted on a database upgrade since it is in the list of unused options. On multisite it is a network option, so it is no longer primed and is now deleted by `upgrade_network()`, with the database version bumped for that step.
Developed in https://github.com/WordPress/wordpress-develop/pull/14412.
Follow-up to r10357, r43580, r64485.
Props azaozz, juzar, tofandel, szepeviktor, irozum, oglekler, peterwilsoncc, westonruter.
See #57548, #63017.
Fixes #58302, #65750, #65980.
Built from https://develop.svn.wordpress.org/trunk@64486
git-svn-id: http://core.svn.wordpress.org/trunk@63636 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index 5e3d484fae..e62c285fa3 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -47,7 +47,6 @@ do_action( 'admin_init' );
$core_actions_get = array(
'fetch-list',
'ajax-tag-search',
- 'wp-compression-test',
'imgedit-preview',
'oembed-cache',
'autocomplete-user',
diff --git a/wp-admin/admin-footer.php b/wp-admin/admin-footer.php
index 32f24e536e..8175e9d4d4 100644
--- a/wp-admin/admin-footer.php
+++ b/wp-admin/admin-footer.php
@@ -104,13 +104,6 @@ do_action( 'admin_print_footer_scripts' );
*/
do_action( "admin_footer-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
-// get_site_option() won't exist when auto upgrading from <= 2.7.
-if ( function_exists( 'get_site_option' )
- && false === get_site_option( 'can_compress_scripts' )
-) {
- compression_test();
-}
-
?>
<div class="clear"></div></div><!-- wpwrap -->
diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php
index cbf412ce4c..03fefef068 100644
--- a/wp-admin/includes/ajax-actions.php
+++ b/wp-admin/includes/ajax-actions.php
@@ -177,76 +177,6 @@ function wp_ajax_ajax_tag_search() {
wp_die();
}
-/**
- * Handles compression testing via AJAX.
- *
- * @since 3.1.0
- */
-function wp_ajax_wp_compression_test() {
- if ( ! current_user_can( 'manage_options' ) ) {
- wp_die( -1 );
- }
-
- if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ) {
- // Use `update_option()` on single site to mark the option for autoloading.
- if ( is_multisite() ) {
- update_site_option( 'can_compress_scripts', 0 );
- } else {
- update_option( 'can_compress_scripts', 0, true );
- }
- wp_die( 0 );
- }
-
- if ( isset( $_GET['test'] ) ) {
- header( 'Expires: Wed, 11 Jan 1984 05:00:00 GMT' );
- header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
- header( 'Cache-Control: no-cache, must-revalidate, max-age=0' );
- header( 'Content-Type: application/javascript; charset=UTF-8' );
- $force_gzip = ( defined( 'ENFORCE_GZIP' ) && ENFORCE_GZIP );
- $test_str = '"wpCompressionTest Lorem ipsum dolor sit amet consectetuer mollis sapien urna ut a. Eu nonummy condimentum fringilla tempor pretium platea vel nibh netus Maecenas. Hac molestie amet justo quis pellentesque est ultrices interdum nibh Morbi. Cras mattis pretium Phasellus ante ipsum ipsum ut sociis Suspendisse Lorem. Ante et non molestie. Porta urna Vestibulum egestas id congue nibh eu risus gravida sit. Ac augue auctor Ut et non a elit massa id sodales. Elit eu Nulla at nibh adipiscing mattis lacus mauris at tempus. Netus nibh quis suscipit nec feugiat eget sed lorem et urna. Pellentesque lacus at ut massa consectetuer ligula ut auctor semper Pellentesque. Ut metus massa nibh quam Curabitur molestie nec mauris congue. Volutpat molestie elit justo facilisis neque ac risus Ut nascetur tristique. Vitae sit lorem tellus et quis Phasellus lacus tincidunt nunc Fusce. Pharetra wisi Suspendisse mus sagittis libero lacinia Integer consequat ac Phasellus. Et urna ac cursus tortor aliquam Aliquam amet tellus volutpat Vestibulum. Justo interdum condimentum In augue congue tellus sollicitudin Quisque quis nibh."';
-
- if ( '1' === $_GET['test'] ) {
- echo $test_str;
- wp_die();
- } elseif ( '2' === $_GET['test'] ) {
- if ( ! isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) ) {
- wp_die( -1 );
- }
-
- if ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate' ) && function_exists( 'gzdeflate' ) && ! $force_gzip ) {
- header( 'Content-Encoding: deflate' );
- $output = gzdeflate( $test_str, 1 );
- } elseif ( false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && function_exists( 'gzencode' ) ) {
- header( 'Content-Encoding: gzip' );
- $output = gzencode( $test_str, 1 );
- } else {
- wp_die( -1 );
- }
-
- echo $output;
- wp_die();
- } elseif ( 'no' === $_GET['test'] ) {
- check_ajax_referer( 'update_can_compress_scripts' );
- // Use `update_option()` on single site to mark the option for autoloading.
- if ( is_multisite() ) {
- update_site_option( 'can_compress_scripts', 0 );
- } else {
- update_option( 'can_compress_scripts', 0, true );
- }
- } elseif ( 'yes' === $_GET['test'] ) {
- check_ajax_referer( 'update_can_compress_scripts' );
- // Use `update_option()` on single site to mark the option for autoloading.
- if ( is_multisite() ) {
- update_site_option( 'can_compress_scripts', 1 );
- } else {
- update_option( 'can_compress_scripts', 1, true );
- }
- }
- }
-
- wp_die( 0 );
-}
-
/**
* Handles image editor previews via AJAX.
*
diff --git a/wp-admin/includes/deprecated.php b/wp-admin/includes/deprecated.php
index 1dcf08a0a3..1a7eee4811 100644
--- a/wp-admin/includes/deprecated.php
+++ b/wp-admin/includes/deprecated.php
@@ -1600,3 +1600,27 @@ function image_attachment_fields_to_save( $post, $attachment ) {
function delete_users_add_js() {
_deprecated_function( __FUNCTION__, '7.1.0' );
}
+
+/**
+ * Was used to output JavaScript that tested whether compressing scripts from PHP works.
+ *
+ * The scripts and styles have not been compressed from PHP since 4.9.9, so the result
+ * of the test went unused.
+ *
+ * @since 2.8.0
+ * @deprecated 7.2.0
+ */
+function compression_test() {
+ _deprecated_function( __FUNCTION__, '7.2.0' );
+}
+
+/**
+ * Was used to handle the compression test via AJAX.
+ *
+ * @since 3.1.0
+ * @deprecated 7.2.0
+ */
+function wp_ajax_wp_compression_test() {
+ _deprecated_function( __FUNCTION__, '7.2.0' );
+ wp_die( 0 );
+}
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index c01d9ffaf8..973e7486db 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -2544,70 +2544,6 @@ function get_media_states( $post ) {
return apply_filters( 'display_media_states', $media_states, $post );
}
-/**
- * Tests support for compressing JavaScript from PHP.
- *
- * Outputs JavaScript that tests if compression from PHP works as expected
- * and sets an option with the result. Has no effect when the current user
- * is not an administrator. To run the test again the option 'can_compress_scripts'
- * has to be deleted.
- *
- * @since 2.8.0
- */
-function compression_test() {
- ?>
- <script>
- var compressionNonce = <?php echo wp_json_encode( wp_create_nonce( 'update_can_compress_scripts' ), JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>;
- var testCompression = {
- get : function(test) {
- var x;
- if ( window.XMLHttpRequest ) {
- x = new XMLHttpRequest();
- } else {
- try{x=new ActiveXObject('Msxml2.XMLHTTP');}catch(e){try{x=new ActiveXObject('Microsoft.XMLHTTP');}catch(e){};}
- }
-
- if (x) {
- x.onreadystatechange = function() {
- var r, h;
- if ( x.readyState == 4 ) {
- r = x.responseText.substr(0, 18);
- h = x.getResponseHeader('Content-Encoding');
- testCompression.check(r, h, test);
- }
- };
-
- x.open('GET', ajaxurl + '?action=wp-compression-test&test='+test+'&_ajax_nonce='+compressionNonce+'&'+(new Date()).getTime(), true);
- x.send('');
- }
- },
-
- check : function(r, h, test) {
- if ( ! r && ! test )
- this.get(1);
-
- if ( 1 == test ) {
- if ( h && ( h.match(/deflate/i) || h.match(/gzip/i) ) )
- this.get('no');
- else
- this.get(2);
-
- return;
- }
-
- if ( 2 == test ) {
- if ( '"wpCompressionTest' === r )
- this.get('yes');
- else
- this.get('no');
- }
- }
- };
- testCompression.check();
- </script>
- <?php
-}
-
/**
* Echoes a submit button, with provided text and appropriate class(es).
*
diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php
index 0f186b4bcd..0131f899e3 100644
--- a/wp-admin/includes/upgrade.php
+++ b/wp-admin/includes/upgrade.php
@@ -2673,6 +2673,12 @@ function upgrade_network() {
delete_network_option( $network_id, 'site_meta_supported' );
is_site_meta_supported();
}
+
+ // 7.2.0
+ if ( $wp_current_db_version < 64486 ) {
+ // The compression test that set this option was removed.
+ delete_site_option( 'can_compress_scripts' );
+ }
}
//
diff --git a/wp-includes/option.php b/wp-includes/option.php
index af954466a8..8bb89b7ceb 100644
--- a/wp-includes/option.php
+++ b/wp-includes/option.php
@@ -802,7 +802,7 @@ function wp_load_core_site_options( $network_id = null ) {
if ( ! is_multisite() || wp_installing() ) {
return;
}
- $core_options = array( 'site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting', 'WPLANG' );
+ $core_options = array( 'site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'global_terms_enabled', 'ms_files_rewriting', 'WPLANG' );
wp_prime_network_option_caches( $network_id, $core_options );
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index bfae13a163..33510ca9d3 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,14 +16,14 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-64485';
+$wp_version = '7.2-alpha-64486';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
*
* @global int $wp_db_version
*/
-$wp_db_version = 64402;
+$wp_db_version = 64486;
/**
* Holds the TinyMCE version.