Changeset 42343 for trunk/src/wp-cron.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-cron.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-cron.php
r41276 r42343 17 17 */ 18 18 19 ignore_user_abort( true);19 ignore_user_abort( true ); 20 20 21 if ( ! empty($_POST) || defined('DOING_AJAX') || defined('DOING_CRON') )21 if ( ! empty( $_POST ) || defined( 'DOING_AJAX' ) || defined( 'DOING_CRON' ) ) { 22 22 die(); 23 } 23 24 24 25 /** … … 27 28 * @var bool 28 29 */ 29 define( 'DOING_CRON', true);30 define( 'DOING_CRON', true ); 30 31 31 if ( ! defined('ABSPATH') ) {32 if ( ! defined( 'ABSPATH' ) ) { 32 33 /** Set up WordPress environment */ 33 34 require_once( dirname( __FILE__ ) . '/wp-load.php' ); … … 58 59 } else { 59 60 $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", '_transient_doing_cron' ) ); 60 if ( is_object( $row ) ) 61 if ( is_object( $row ) ) { 61 62 $value = $row->option_value; 63 } 62 64 } 63 65 … … 65 67 } 66 68 67 if ( false === $crons = _get_cron_array() ) 69 if ( false === $crons = _get_cron_array() ) { 68 70 die(); 71 } 69 72 70 $keys = array_keys( $crons );73 $keys = array_keys( $crons ); 71 74 $gmt_time = microtime( true ); 72 75 73 if ( isset( $keys[0]) && $keys[0] > $gmt_time )76 if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) { 74 77 die(); 78 } 75 79 76 80 … … 80 84 // Use global $doing_wp_cron lock otherwise use the GET lock. If no lock, trying grabbing a new lock. 81 85 if ( empty( $doing_wp_cron ) ) { 82 if ( empty( $_GET[ 'doing_wp_cron'] ) ) {86 if ( empty( $_GET['doing_wp_cron'] ) ) { 83 87 // Called from external script/job. Try setting a lock. 84 if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $gmt_time ) ) 88 if ( $doing_cron_transient && ( $doing_cron_transient + WP_CRON_LOCK_TIMEOUT > $gmt_time ) ) { 85 89 return; 90 } 86 91 $doing_cron_transient = $doing_wp_cron = sprintf( '%.22F', microtime( true ) ); 87 92 set_transient( 'doing_cron', $doing_wp_cron ); 88 93 } else { 89 $doing_wp_cron = $_GET[ 'doing_wp_cron'];94 $doing_wp_cron = $_GET['doing_wp_cron']; 90 95 } 91 96 } … … 95 100 * must match $doing_wp_cron (the "key"). 96 101 */ 97 if ( $doing_cron_transient != $doing_wp_cron ) 102 if ( $doing_cron_transient != $doing_wp_cron ) { 98 103 return; 104 } 99 105 100 106 foreach ( $crons as $timestamp => $cronhooks ) { 101 if ( $timestamp > $gmt_time ) 107 if ( $timestamp > $gmt_time ) { 102 108 break; 109 } 103 110 104 111 foreach ( $cronhooks as $hook => $keys ) { … … 109 116 110 117 if ( $schedule != false ) { 111 $new_args = array( $timestamp, $schedule, $hook, $v['args']);112 call_user_func_array( 'wp_reschedule_event', $new_args);118 $new_args = array( $timestamp, $schedule, $hook, $v['args'] ); 119 call_user_func_array( 'wp_reschedule_event', $new_args ); 113 120 } 114 121 … … 124 131 * @param array $args The arguments to be passed to the hook. 125 132 */ 126 do_action_ref_array( $hook, $v['args'] );133 do_action_ref_array( $hook, $v['args'] ); 127 134 128 135 // If the hook ran too long and another cron process stole the lock, quit. 129 if ( _get_cron_lock() != $doing_wp_cron ) 136 if ( _get_cron_lock() != $doing_wp_cron ) { 130 137 return; 138 } 131 139 } 132 140 } 133 141 } 134 142 135 if ( _get_cron_lock() == $doing_wp_cron ) 143 if ( _get_cron_lock() == $doing_wp_cron ) { 136 144 delete_transient( 'doing_cron' ); 145 } 137 146 138 147 die();
Note: See TracChangeset
for help on using the changeset viewer.