Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 2 changed files with 7 additions and 7 deletions. Show diff stats Hide diff stats

  1. +2 2 wp-cron.php
  2. +5 5 wp-includes/cron.php
4 wp-cron.php
@@ -48,7 +48,7 @@ function _get_cron_lock() {
48 48 die();
49 49
50 50 $keys = array_keys( $crons );
51   -$local_time = time();
  51 +$local_time = microtime( true );
52 52
53 53 if ( isset($keys[0]) && $keys[0] > $local_time )
54 54 die();
@@ -61,7 +61,7 @@ function _get_cron_lock() {
61 61 // Called from external script/job. Try setting a lock.
62 62 if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $local_time ) )
63 63 return;
64   - $doing_cron_transient = $doing_wp_cron = time();
  64 + $doing_cron_transient = $doing_wp_cron = sprintf( '%.22F', microtime( true ) );
65 65 set_transient( 'doing_cron', $doing_wp_cron );
66 66 } else {
67 67 $doing_wp_cron = $_GET[ 'doing_wp_cron' ];
10 wp-includes/cron.php
@@ -194,8 +194,8 @@ function wp_next_scheduled( $hook, $args = array() ) {
194 194 */
195 195 function spawn_cron( $local_time = 0 ) {
196 196
197   - if ( !$local_time )
198   - $local_time = time();
  197 + if ( ! $local_time )
  198 + $local_time = microtime( true );
199 199
200 200 if ( defined('DOING_CRON') || isset($_GET['doing_wp_cron']) )
201 201 return;
@@ -226,7 +226,7 @@ function spawn_cron( $local_time = 0 ) {
226 226 if ( !empty($_POST) || defined('DOING_AJAX') )
227 227 return;
228 228
229   - $doing_wp_cron = $local_time;
  229 + $doing_wp_cron = sprintf( '%.22F', $local_time );
230 230 set_transient( 'doing_cron', $doing_wp_cron );
231 231
232 232 ob_start();
@@ -241,7 +241,7 @@ function spawn_cron( $local_time = 0 ) {
241 241 return;
242 242 }
243 243
244   - $doing_wp_cron = $local_time;
  244 + $doing_wp_cron = sprintf( '%.22F', $local_time );
245 245 set_transient( 'doing_cron', $doing_wp_cron );
246 246
247 247 $cron_url = get_option( 'siteurl' ) . '/wp-cron.php?doing_wp_cron=' . $doing_wp_cron;
@@ -264,7 +264,7 @@ function wp_cron() {
264 264 if ( false === $crons = _get_cron_array() )
265 265 return;
266 266
267   - $local_time = time();
  267 + $local_time = microtime( true );
268 268 $keys = array_keys( $crons );
269 269 if ( isset($keys[0]) && $keys[0] > $local_time )
270 270 return;

0 comments on commit 2f915b5

Please sign in to comment.
Something went wrong with that request. Please try again.