Make WordPress Core

Changeset 54113


Ignore:
Timestamp:
09/09/2022 08:14:43 AM (2 years ago)
Author:
audrasjb
Message:

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.

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-debug-data.php

    r53426 r54113  
    15981598        // We still want to limit it below.
    15991599        if ( empty( $max_execution_time ) ) {
    1600             $max_execution_time = 30;
     1600            $max_execution_time = 30; // 30 seconds.
    16011601        }
    16021602
  • trunk/src/wp-admin/includes/class-wp-site-health.php

    r54069 r54113  
    20302030
    20312031        $cookies = wp_unslash( $_COOKIE );
    2032         $timeout = 10;
     2032        $timeout = 10; // 10 seconds.
    20332033        $headers = array(
    20342034            'Cache-Control' => 'no-cache',
     
    28862886        $body    = array( 'site-health' => 'loopback-test' );
    28872887        $cookies = wp_unslash( $_COOKIE );
    2888         $timeout = 10;
     2888        $timeout = 10; // 10 seconds.
    28892889        $headers = array(
    28902890            'Cache-Control' => 'no-cache',
  • trunk/src/wp-admin/includes/file.php

    r53714 r54113  
    540540
    541541        // Make sure PHP process doesn't die before loopback requests complete.
    542         set_time_limit( 300 );
     542        set_time_limit( 5 * MINUTE_IN_SECONDS );
    543543
    544544        // Time to wait for loopback requests to finish.
    545         $timeout = 100;
     545        $timeout = 100; // 100 seconds.
    546546
    547547        $needle_start = "###### wp_scraping_result_start:$scrape_key ######";
     
    20082008     */
    20092009    if ( ! defined( 'FS_CONNECT_TIMEOUT' ) ) {
    2010         define( 'FS_CONNECT_TIMEOUT', MINUTE_IN_SECONDS / 2 );
     2010        define( 'FS_CONNECT_TIMEOUT', 30 ); // 30 seconds.
    20112011    }
    20122012    if ( ! defined( 'FS_TIMEOUT' ) ) {
    2013         define( 'FS_TIMEOUT', MINUTE_IN_SECONDS / 2 );
     2013        define( 'FS_TIMEOUT', 30 ); // 30 seconds.
    20142014    }
    20152015
  • trunk/src/wp-admin/options-permalink.php

    r53911 r54113  
    204204    }
    205205
    206     set_transient( 'settings_errors', get_settings_errors(), MINUTE_IN_SECONDS / 2 );
     206    set_transient( 'settings_errors', get_settings_errors(), 30 ); // 30 seconds.
    207207
    208208    wp_redirect( admin_url( 'options-permalink.php?settings-updated=true' ) );
  • trunk/src/wp-admin/options.php

    r53714 r54113  
    346346    }
    347347
    348     set_transient( 'settings_errors', get_settings_errors(), MINUTE_IN_SECONDS / 2 );
     348    set_transient( 'settings_errors', get_settings_errors(), 30 ); // 30 seconds.
    349349
    350350    // Redirect back to the settings page that was submitted.
  • trunk/src/wp-includes/update.php

    r53933 r54113  
    406406
    407407    if ( $doing_cron ) {
    408         $timeout = 30;
     408        $timeout = 30; // 30 seconds.
    409409    } else {
    410410        // Three seconds, plus one extra second for every 10 plugins.
     
    688688
    689689    if ( $doing_cron ) {
    690         $timeout = 30;
     690        $timeout = 30; // 30 seconds.
    691691    } else {
    692692        // Three seconds, plus one extra second for every 10 themes.
Note: See TracChangeset for help on using the changeset viewer.