Use microtime() for cron locks. fixes #19700

git-svn-id: https://develop.svn.wordpress.org/trunk@19722 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2012-01-09 19:02:31 +00:00
parent e1b429fd67
commit 3a1b732f51
2 changed files with 7 additions and 7 deletions

View File

@ -48,7 +48,7 @@ if ( false === $crons = _get_cron_array() )
die(); die();
$keys = array_keys( $crons ); $keys = array_keys( $crons );
$local_time = time(); $local_time = microtime( true );
if ( isset($keys[0]) && $keys[0] > $local_time ) if ( isset($keys[0]) && $keys[0] > $local_time )
die(); die();
@ -61,7 +61,7 @@ if ( empty( $doing_wp_cron ) ) {
// Called from external script/job. Try setting a lock. // Called from external script/job. Try setting a lock.
if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $local_time ) ) if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $local_time ) )
return; 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 ); set_transient( 'doing_cron', $doing_wp_cron );
} else { } else {
$doing_wp_cron = $_GET[ 'doing_wp_cron' ]; $doing_wp_cron = $_GET[ 'doing_wp_cron' ];

View File

@ -194,8 +194,8 @@ function wp_next_scheduled( $hook, $args = array() ) {
*/ */
function spawn_cron( $local_time = 0 ) { function spawn_cron( $local_time = 0 ) {
if ( !$local_time ) if ( ! $local_time )
$local_time = time(); $local_time = microtime( true );
if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) ) if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) )
return; return;
@ -226,7 +226,7 @@ function spawn_cron( $local_time = 0 ) {
if ( !empty($_POST) || defined('DOING_AJAX') ) if ( !empty($_POST) || defined('DOING_AJAX') )
return; return;
$doing_wp_cron = $local_time; $doing_wp_cron = sprintf( '%.22F', $local_time );
set_transient( 'doing_cron', $doing_wp_cron ); set_transient( 'doing_cron', $doing_wp_cron );
ob_start(); ob_start();
@ -241,7 +241,7 @@ function spawn_cron( $local_time = 0 ) {
return; return;
} }
$doing_wp_cron = $local_time; $doing_wp_cron = sprintf( '%.22F', $local_time );
set_transient( 'doing_cron', $doing_wp_cron ); set_transient( 'doing_cron', $doing_wp_cron );
$cron_url = get_option( 'siteurl' ) . '/wp-cron.php?doing_wp_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() ) if ( false === $crons = _get_cron_array() )
return; return;
$local_time = time(); $local_time = microtime( true );
$keys = array_keys( $crons ); $keys = array_keys( $crons );
if ( isset($keys[0]) && $keys[0] > $local_time ) if ( isset($keys[0]) && $keys[0] > $local_time )
return; return;