Ticket #17462: 17462.diff
File 17462.diff, 4.1 KB (added by , 12 years ago) |
---|
-
wp-includes/cache.php
172 172 * 173 173 * @since 2.6.0 174 174 */ 175 function wp_cache_reset( ) {175 function wp_cache_reset( $group = '', $key = '' ) { 176 176 global $wp_object_cache; 177 177 178 return $wp_object_cache->reset( );178 return $wp_object_cache->reset( $group, $key ); 179 179 } 180 180 181 181 /** … … 390 390 * 391 391 * @since 3.0.0 392 392 */ 393 function reset() { 394 // Clear out non-global caches since the blog ID has changed. 395 foreach ( array_keys($this->cache) as $group ) { 396 if ( !in_array($group, $this->global_groups) ) 397 unset($this->cache[$group]); 393 function reset( $group = '', $id = '' ) { 394 if ( ! empty( $group ) ) { 395 if ( !empty( $id ) ) { 396 // Clear out a particular key 397 if ( isset( $this->cache[$group][$id] ) ) 398 unset( $this->cache[$group][$id] ); 399 } else { 400 // Clear out a particular group 401 if ( isset( $this->cache[$group] ) ) 402 unset( $this->cache[$group] ); 403 } 404 } else { 405 // Clear out non-global caches since the blog ID has changed. 406 foreach ( array_keys($this->cache) as $group ) { 407 if ( !in_array($group, $this->global_groups) ) 408 unset($this->cache[$group]); 409 } 398 410 } 399 411 } 400 412 -
wp-includes/cron.php
204 204 * multiple processes on multiple web servers can run this code concurrently 205 205 * try to make this as atomic as possible by setting doing_cron switch 206 206 */ 207 $ flag= get_transient('doing_cron');207 $lock = get_transient('doing_cron'); 208 208 209 if ( $ flag> $local_time + 10*60 )210 $ flag= 0;209 if ( $lock > $local_time + 10*60 ) 210 $lock = 0; 211 211 212 212 // don't run if another process is currently running it or more than once every 60 sec. 213 if ( $ flag+ 60 > $local_time )213 if ( $lock + 60 > $local_time ) 214 214 return; 215 215 216 216 //sanity check … … 227 227 return; 228 228 229 229 set_transient( 'doing_cron', $local_time ); 230 $lock = $local_time; 230 231 231 232 ob_start(); 232 233 wp_redirect( add_query_arg('doing_wp_cron', '', stripslashes($_SERVER['REQUEST_URI'])) ); … … 241 242 } 242 243 243 244 set_transient( 'doing_cron', $local_time ); 245 $lock = $local_time; 244 246 245 $cron_url = get_option( 'siteurl' ) . '/wp-cron.php? doing_wp_cron';247 $cron_url = get_option( 'siteurl' ) . '/wp-cron.php?lock=' . $lock; 246 248 wp_remote_post( $cron_url, array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true)) ); 247 249 } 248 250 -
wp-cron.php
26 26 require_once('./wp-load.php'); 27 27 } 28 28 29 // Uncached doing_cron transient fetch 30 function _get_cron_lock() { 31 global $_wp_using_ext_object_cache, $wpdb; 32 33 $value = 0; 34 if ( $_wp_using_ext_object_cache ) { 35 // Clear the internal cache for the doing_cron transient to force a cache refresh 36 if ( function_exists( 'wp_cache_reset' ) ) 37 wp_cache_reset( 'transient', 'doing_cron' ); 38 $value = wp_cache_get( $transient, 'transient' ); 39 } else { 40 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", '_transient_doing_cron' ) ); 41 if ( is_object( $row ) ) 42 $value = $row->option_value; 43 } 44 45 return $value; 46 } 47 29 48 if ( false === $crons = _get_cron_array() ) 30 49 die(); 31 50 51 // Use global $lock otherwise GET lock. 52 if ( empty( $lock ) ) { 53 if ( empty( $_GET[ 'lock' ] ) ) 54 return; 55 $lock = $_GET[ 'lock' ]; 56 } 57 32 58 $keys = array_keys( $crons ); 33 59 $local_time = time(); 34 60 35 61 if ( isset($keys[0]) && $keys[0] > $local_time ) 36 62 die(); 37 63 64 // Check lock 65 if ( get_transient( 'doing_cron') != $lock ) 66 return; 67 38 68 foreach ($crons as $timestamp => $cronhooks) { 39 69 if ( $timestamp > $local_time ) 40 70 break; … … 53 83 wp_unschedule_event($timestamp, $hook, $v['args']); 54 84 55 85 do_action_ref_array($hook, $v['args']); 86 87 // Has another cron process grabbed the lock? 88 if ( _get_cron_lock() != $lock ) 89 return; 56 90 } 57 91 } 58 92 }