From 3a1b732f51c27c4820a6831a6e9c496e232c8cdd Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 9 Jan 2012 19:02:31 +0000 Subject: [PATCH] Use microtime() for cron locks. fixes #19700 git-svn-id: https://develop.svn.wordpress.org/trunk@19722 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-cron.php | 4 ++-- wp-includes/cron.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wp-cron.php b/wp-cron.php index a84c4635df..f0da6ecc5c 100644 --- a/wp-cron.php +++ b/wp-cron.php @@ -48,7 +48,7 @@ if ( false === $crons = _get_cron_array() ) die(); $keys = array_keys( $crons ); -$local_time = time(); +$local_time = microtime( true ); if ( isset($keys[0]) && $keys[0] > $local_time ) die(); @@ -61,7 +61,7 @@ if ( empty( $doing_wp_cron ) ) { // Called from external script/job. Try setting a lock. if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $local_time ) ) return; - $doing_cron_transient = $doing_wp_cron = time(); + $doing_cron_transient = $doing_wp_cron = sprintf( '%.22F', microtime( true ) ); set_transient( 'doing_cron', $doing_wp_cron ); } else { $doing_wp_cron = $_GET[ 'doing_wp_cron' ]; diff --git a/wp-includes/cron.php b/wp-includes/cron.php index f3c090feb4..a300569ce9 100644 --- a/wp-includes/cron.php +++ b/wp-includes/cron.php @@ -194,8 +194,8 @@ function wp_next_scheduled( $hook, $args = array() ) { */ function spawn_cron( $local_time = 0 ) { - if ( !$local_time ) - $local_time = time(); + if ( ! $local_time ) + $local_time = microtime( true ); if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) ) return; @@ -226,7 +226,7 @@ function spawn_cron( $local_time = 0 ) { if ( !empty($_POST) || defined('DOING_AJAX') ) return; - $doing_wp_cron = $local_time; + $doing_wp_cron = sprintf( '%.22F', $local_time ); set_transient( 'doing_cron', $doing_wp_cron ); ob_start(); @@ -241,7 +241,7 @@ function spawn_cron( $local_time = 0 ) { return; } - $doing_wp_cron = $local_time; + $doing_wp_cron = sprintf( '%.22F', $local_time ); set_transient( 'doing_cron', $doing_wp_cron ); $cron_url = get_option( 'siteurl' ) . '/wp-cron.php?doing_wp_cron=' . $doing_wp_cron; @@ -264,7 +264,7 @@ function wp_cron() { if ( false === $crons = _get_cron_array() ) return; - $local_time = time(); + $local_time = microtime( true ); $keys = array_keys( $crons ); if ( isset($keys[0]) && $keys[0] > $local_time ) return;