Ticket #45797: 45797.diff
File 45797.diff, 2.5 KB (added by , 7 years ago) |
---|
-
src/wp-cron.php
diff --git a/src/wp-cron.php b/src/wp-cron.php index acf5ded2d4..d704ceaf84 100644
a b function _get_cron_lock() { 66 66 return $value; 67 67 } 68 68 69 if ( false === $crons = _get_cron_array() ) { 69 $crons = wp_get_ready_cron_jobs(); 70 if ( empty( $crons ) ) { 70 71 die(); 71 72 } 72 73 73 $keys = array_keys( $crons );74 $gmt_time = microtime( true );75 76 if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {77 die();78 }79 80 81 74 // The cron lock: a unix timestamp from when the cron was spawned. 82 75 $doing_cron_transient = get_transient( 'doing_cron' ); 83 76 -
src/wp-includes/cron.php
diff --git a/src/wp-includes/cron.php b/src/wp-includes/cron.php index 046c0dca73..16430f1df4 100644
a b function spawn_cron( $gmt_time = 0 ) { 641 641 } 642 642 643 643 //sanity check 644 $crons = _get_cron_array();645 if ( ! is_array( $crons ) ) {644 $crons = wp_get_ready_cron_jobs(); 645 if ( empty( $crons ) ) { 646 646 return false; 647 647 } 648 648 … … function wp_cron() { 736 736 return 0; 737 737 } 738 738 739 $crons = _get_cron_array();740 if ( false === $crons) {739 $crons = wp_get_ready_cron_jobs(); 740 if ( empty( $crons ) ) { 741 741 return 0; 742 742 } 743 743 … … function wp_get_schedule( $hook, $args = array() ) { 854 854 return apply_filters( 'get_schedule', $schedule, $hook, $args ); 855 855 } 856 856 857 /** 858 * Retrieve cron jobs ready to be run. 859 * 860 * Returns the results of _get_cron_array() limited to events ready to be run, 861 * ie, with a timestamp in the past. 862 * 863 * @return array Cron jobs ready to be run. 864 */ 865 function wp_get_ready_cron_jobs() { 866 /** 867 * Filter to preflight or hijack retrieving ready cron jobs. 868 * 869 * Returning an array will short-circuit the normal retrieval of ready 870 * cron jobs, causing the function to return the filtered value instead. 871 * 872 * @param null|array $pre Array of ready cron tasks to return instead. Default null 873 * to continue using results from _get_cron_array(). 874 */ 875 $pre = apply_filters( 'pre_get_ready_cron_jobs', null ); 876 if ( null !== $pre ) { 877 return $pre; 878 } 879 880 $crons = _get_cron_array(); 881 882 if ( false === $crons ) { 883 return array(); 884 } 885 886 $gmt_time = microtime( true ); 887 $keys = array_keys( $crons ); 888 if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) { 889 return array(); 890 } 891 892 $results = array(); 893 foreach ( $crons as $timestamp => $cronhooks ) { 894 if ( $timestamp > $gmt_time ) { 895 break; 896 } 897 $results[ $timestamp ] = $cronhooks; 898 } 899 900 return $results; 901 } 902 857 903 // 858 904 // Private functions 859 905 //