Ticket #45797: 45797.2.diff
File 45797.2.diff, 2.5 KB (added by , 6 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..c6bb637092 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 * @since 5.1.0 864 * 865 * @return array Cron jobs ready to be run. 866 */ 867 function wp_get_ready_cron_jobs() { 868 /** 869 * Filter to preflight or hijack retrieving ready cron jobs. 870 * 871 * Returning an array will short-circuit the normal retrieval of ready 872 * cron jobs, causing the function to return the filtered value instead. 873 * 874 * @since 5.1.0 875 * 876 * @param null|array $pre Array of ready cron tasks to return instead. Default null 877 * to continue using results from _get_cron_array(). 878 */ 879 $pre = apply_filters( 'pre_get_ready_cron_jobs', null ); 880 if ( null !== $pre ) { 881 return $pre; 882 } 883 884 $crons = _get_cron_array(); 885 886 if ( false === $crons ) { 887 return array(); 888 } 889 890 $gmt_time = microtime( true ); 891 $keys = array_keys( $crons ); 892 if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) { 893 return array(); 894 } 895 896 $results = array(); 897 foreach ( $crons as $timestamp => $cronhooks ) { 898 if ( $timestamp > $gmt_time ) { 899 break; 900 } 901 $results[ $timestamp ] = $cronhooks; 902 } 903 904 return $results; 905 } 906 857 907 // 858 908 // Private functions 859 909 //