WordPress.org

Make WordPress Core

Ticket #39163: large.diff

File large.diff, 3.7 KB (added by andy, 3 years ago)
  • wp-admin/upgrade.php

     
    1919
    2020nocache_headers();
    2121
    22 timer_start();
    2322require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    2423
    2524delete_site_transient('update_core');
  • wp-includes/load.php

     
    55 * @package WordPress
    66 */
    77
     8// Compat for PHP < 5.4.0
     9if ( !isset( $_SERVER['REQUEST_TIME_FLOAT'] ) )
     10        $_SERVER['REQUEST_TIME_FLOAT'] = microtime( true );
     11
     12// Start the request timer
     13$GLOBALS['timestart'] = $_SERVER['REQUEST_TIME_FLOAT'];
     14
    815/**
    916 * Return the HTTP protocol sent by the server.
    1017 *
     
    228235}
    229236
    230237/**
    231  * Start the WordPress micro-timer.
    232  *
    233238 * @since 0.71
    234239 * @access private
    235  *
    236  * @global float $timestart Unix timestamp set at the beginning of the page load.
     240 * @deprecated
    237241 * @see timer_stop()
    238  *
    239242 * @return bool Always returns true.
    240243 */
    241244function timer_start() {
    242         global $timestart;
    243         $timestart = microtime( true );
    244245        return true;
    245246}
    246247
    247248/**
     249 * Get the time elapsed so far during this PHP script.
     250 *
     251 * REQUEST_TIME_FLOAT appeared in PHP 5.4.0.
     252 *
     253 * @since
     254 *
     255 * @return float Seconds since the PHP script started.
     256 */
     257function timer_float() {
     258        return microtime( true ) - $_SERVER['REQUEST_TIME_FLOAT'];
     259}
     260
     261/**
    248262 * Retrieve or display the time from the page start to when function is called.
    249263 *
     264 * WARNING: Due to localization, the resulting string can not reliably be used
     265 * as a number. Some locales swap the commas and periods.
     266 * Example: number_format_i18n( 1000 ) => '1.000,0'
     267 * For accurate timing data, use timer_float().
     268 *
    250269 * @since 0.71
    251270 *
    252  * @global float   $timestart Seconds from when timer_start() is called.
    253  * @global float   $timeend   Seconds from when function is called.
     271 * @global float  $timestart Timestamp from start of PHP script.
     272 * @global float  $timeend   Timestamp from last call to timer_stop().
    254273 *
    255  * @param int|bool $display   Whether to echo or return the results. Accepts 0|false for return,
    256  *                            1|true for echo. Default 0|false.
    257  * @param int      $precision The number of digits from the right of the decimal to display.
    258  *                            Default 3.
    259  * @return string The "second.microsecond" finished time calculation. The number is formatted
     274 * @param bool    $display   Whether to echo the results. Default false.
     275 * @param int     $precision The number of decimal digits. Default 3 (millisecond precision).
     276 * @return string The "second.millisecond" finished time calculation. The number is formatted
    260277 *                for human consumption, both localized and rounded.
    261278 */
    262 function timer_stop( $display = 0, $precision = 3 ) {
     279function timer_stop( $display = false, $precision = 3 ) {
    263280        global $timestart, $timeend;
    264         $timeend = microtime( true );
    265         $timetotal = $timeend - $timestart;
    266         $r = ( function_exists( 'number_format_i18n' ) ) ? number_format_i18n( $timetotal, $precision ) : number_format( $timetotal, $precision );
     281        $elapsed = timer_float();
     282        $timeend = $timestart + $elapsed;
     283        if ( function_exists( 'number_format_i18n' ) )
     284                $r = number_format_i18n( $elapsed, $precision );
     285        else
     286                $r = number_format( $elapsed, $precision );
    267287        if ( $display )
    268288                echo $r;
    269289        return $r;
  • wp-settings.php

     
    6262// Check if we're in maintenance mode.
    6363wp_maintenance();
    6464
    65 // Start loading timer.
    66 timer_start();
    67 
    6865// Check if we're in WP_DEBUG mode.
    6966wp_debug_mode();
    7067