From c7fe0f88d289ecd197603f61fa7a7b3c39e45b5d Mon Sep 17 00:00:00 2001 From: audrasjb Date: Fri, 9 Sep 2022 08:16:18 +0000 Subject: [PATCH] Coding Standards: Clarify time units for various timeout or expiration values. This changeset implements a clearer and more consistent timeout/duration/expiration format. It updates time durations used in various files, as per WordPress coding standards: - If the value can be represented as an integer (not a fractional) number of minutes (hours, etc.), use the appropriate constant (e.g.: `MINUTE_IN_SECONDS`) multiplied by that number. - Otherwise, keep the value as is and add a comment with the units for clarity. Follow-up to [11823], [13177], [21996], [37747], [53714]. Props hztyfoon, audrasjb, arrasel403, krupalpanchal, GaryJ, SergeyBiryukov, peterwilsoncc, rudlinkon, costdev, robinwpdeveloper. Fixes #56293. See #55647. Built from https://develop.svn.wordpress.org/trunk@54113 git-svn-id: http://core.svn.wordpress.org/trunk@53672 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-debug-data.php | 2 +- wp-admin/includes/class-wp-site-health.php | 4 ++-- wp-admin/includes/file.php | 8 ++++---- wp-admin/options-permalink.php | 2 +- wp-admin/options.php | 2 +- wp-includes/update.php | 4 ++-- wp-includes/version.php | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/wp-admin/includes/class-wp-debug-data.php b/wp-admin/includes/class-wp-debug-data.php index 7e301f43f4..121a359c37 100644 --- a/wp-admin/includes/class-wp-debug-data.php +++ b/wp-admin/includes/class-wp-debug-data.php @@ -1597,7 +1597,7 @@ class WP_Debug_Data { // The max_execution_time defaults to 0 when PHP runs from cli. // We still want to limit it below. if ( empty( $max_execution_time ) ) { - $max_execution_time = 30; + $max_execution_time = 30; // 30 seconds. } if ( $max_execution_time > 20 ) { diff --git a/wp-admin/includes/class-wp-site-health.php b/wp-admin/includes/class-wp-site-health.php index ae65905554..6a63607c55 100644 --- a/wp-admin/includes/class-wp-site-health.php +++ b/wp-admin/includes/class-wp-site-health.php @@ -2029,7 +2029,7 @@ class WP_Site_Health { ); $cookies = wp_unslash( $_COOKIE ); - $timeout = 10; + $timeout = 10; // 10 seconds. $headers = array( 'Cache-Control' => 'no-cache', 'X-WP-Nonce' => wp_create_nonce( 'wp_rest' ), @@ -2885,7 +2885,7 @@ class WP_Site_Health { public function can_perform_loopback() { $body = array( 'site-health' => 'loopback-test' ); $cookies = wp_unslash( $_COOKIE ); - $timeout = 10; + $timeout = 10; // 10 seconds. $headers = array( 'Cache-Control' => 'no-cache', ); diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 8fe8adeb97..e7083b7999 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -539,10 +539,10 @@ function wp_edit_theme_plugin_file( $args ) { } // Make sure PHP process doesn't die before loopback requests complete. - set_time_limit( 300 ); + set_time_limit( 5 * MINUTE_IN_SECONDS ); // Time to wait for loopback requests to finish. - $timeout = 100; + $timeout = 100; // 100 seconds. $needle_start = "###### wp_scraping_result_start:$scrape_key ######"; $needle_end = "###### wp_scraping_result_end:$scrape_key ######"; @@ -2007,10 +2007,10 @@ function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_own * to allow for per-transport overriding of the default. */ if ( ! defined( 'FS_CONNECT_TIMEOUT' ) ) { - define( 'FS_CONNECT_TIMEOUT', MINUTE_IN_SECONDS / 2 ); + define( 'FS_CONNECT_TIMEOUT', 30 ); // 30 seconds. } if ( ! defined( 'FS_TIMEOUT' ) ) { - define( 'FS_TIMEOUT', MINUTE_IN_SECONDS / 2 ); + define( 'FS_TIMEOUT', 30 ); // 30 seconds. } if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) { diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index 63749233ff..e3eeb83c42 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -203,7 +203,7 @@ if ( $structure_updated ) { add_settings_error( 'general', 'settings_updated', $message, 'success' ); } - set_transient( 'settings_errors', get_settings_errors(), MINUTE_IN_SECONDS / 2 ); + set_transient( 'settings_errors', get_settings_errors(), 30 ); // 30 seconds. wp_redirect( admin_url( 'options-permalink.php?settings-updated=true' ) ); exit; diff --git a/wp-admin/options.php b/wp-admin/options.php index 069b7c980b..400a7b69ae 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -345,7 +345,7 @@ if ( 'update' === $action ) { // We are saving settings sent from a settings pag add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'success' ); } - set_transient( 'settings_errors', get_settings_errors(), MINUTE_IN_SECONDS / 2 ); + set_transient( 'settings_errors', get_settings_errors(), 30 ); // 30 seconds. // Redirect back to the settings page that was submitted. $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); diff --git a/wp-includes/update.php b/wp-includes/update.php index 18465186d1..568116bea5 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -405,7 +405,7 @@ function wp_update_plugins( $extra_stats = array() ) { $locales = array_unique( $locales ); if ( $doing_cron ) { - $timeout = 30; + $timeout = 30; // 30 seconds. } else { // Three seconds, plus one extra second for every 10 plugins. $timeout = 3 + (int) ( count( $plugins ) / 10 ); @@ -687,7 +687,7 @@ function wp_update_themes( $extra_stats = array() ) { $locales = array_unique( $locales ); if ( $doing_cron ) { - $timeout = 30; + $timeout = 30; // 30 seconds. } else { // Three seconds, plus one extra second for every 10 themes. $timeout = 3 + (int) ( count( $themes ) / 10 ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 7617a36523..66044cf594 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-54112'; +$wp_version = '6.1-alpha-54113'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.