Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use microtime() for cron locks. fixes #19700

git-svn-id: http://svn.automattic.com/wordpress/trunk@19722 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
commit 2f915b532024f1ac52e562f5e22fa08d6152271b 1 parent 05c3160
ryan authored
Showing with 7 additions and 7 deletions.
  1. +2 −2 wp-cron.php
  2. +5 −5 wp-includes/cron.php
View
4 wp-cron.php
@@ -48,7 +48,7 @@ function _get_cron_lock() {
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 @@ function _get_cron_lock() {
// 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' ];
View
10 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;
Please sign in to comment.
Something went wrong with that request. Please try again.