Changeset 56394
- Timestamp:
- 08/12/2023 12:00:27 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/cron.php
r56180 r56394 140 140 continue; 141 141 } 142 142 143 if ( $event_timestamp > $max_timestamp ) { 143 144 break; 144 145 } 146 145 147 if ( isset( $cron[ $event->hook ][ $key ] ) ) { 146 148 $duplicate = true; … … 360 362 if ( 0 === $interval ) { 361 363 $scheduled_event = wp_get_scheduled_event( $hook, $args, $timestamp ); 364 362 365 if ( $scheduled_event && isset( $scheduled_event->interval ) ) { 363 366 $interval = $scheduled_event->interval; … … 415 418 416 419 // Now we assume something is wrong and fail to schedule. 417 if ( 0 == $interval ) {420 if ( 0 === $interval ) { 418 421 if ( $wp_error ) { 419 422 return new WP_Error( … … 507 510 $crons = _get_cron_array(); 508 511 $key = md5( serialize( $args ) ); 512 509 513 unset( $crons[ $timestamp ][ $hook ][ $key ] ); 514 510 515 if ( empty( $crons[ $timestamp ][ $hook ] ) ) { 511 516 unset( $crons[ $timestamp ][ $hook ] ); 512 517 } 518 513 519 if ( empty( $crons[ $timestamp ] ) ) { 514 520 unset( $crons[ $timestamp ] ); … … 547 553 */ 548 554 if ( ! is_array( $args ) ) { 549 _deprecated_argument( __FUNCTION__, '3.0.0', __( 'This argument has changed to an array to match the behavior of the other cron functions.' ) ); 555 _deprecated_argument( 556 __FUNCTION__, 557 '3.0.0', 558 __( 'This argument has changed to an array to match the behavior of the other cron functions.' ) 559 ); 560 550 561 $args = array_slice( func_get_args(), 1 ); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection 551 562 $wp_error = false; … … 682 693 683 694 $results = array(); 695 684 696 foreach ( $crons as $timestamp => $args ) { 685 697 if ( ! empty( $crons[ $timestamp ][ $hook ] ) ) { 686 698 $results[] = count( $crons[ $timestamp ][ $hook ] ); 687 699 } 700 688 701 unset( $crons[ $timestamp ][ $hook ] ); 689 702 … … 755 768 */ 756 769 $pre = apply_filters( 'pre_get_scheduled_event', null, $hook, $args, $timestamp ); 770 757 771 if ( null !== $pre ) { 758 772 return $pre; … … 779 793 } 780 794 } 795 781 796 if ( ! $next ) { 782 797 return false; … … 816 831 function wp_next_scheduled( $hook, $args = array() ) { 817 832 $next_event = wp_get_scheduled_event( $hook, $args ); 833 818 834 if ( ! $next_event ) { 819 835 return false; … … 931 947 932 948 $result = wp_remote_post( $cron_request['url'], $cron_request['args'] ); 949 933 950 return ! is_wp_error( $result ); 934 951 } … … 977 994 function _wp_cron() { 978 995 // Prevent infinite loops caused by lack of wp-cron.php. 979 if ( str_contains( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) || ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ) { 996 if ( str_contains( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) 997 || ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) 998 ) { 980 999 return 0; 981 1000 } … … 994 1013 $schedules = wp_get_schedules(); 995 1014 $results = array(); 1015 996 1016 foreach ( $crons as $timestamp => $cronhooks ) { 997 1017 if ( $timestamp > $gmt_time ) { 998 1018 break; 999 1019 } 1020 1000 1021 foreach ( (array) $cronhooks as $hook => $args ) { 1001 if ( isset( $schedules[ $hook ]['callback'] ) && ! call_user_func( $schedules[ $hook ]['callback'] ) ) { 1022 if ( isset( $schedules[ $hook ]['callback'] ) 1023 && ! call_user_func( $schedules[ $hook ]['callback'] ) 1024 ) { 1002 1025 continue; 1003 1026 } 1027 1004 1028 $results[] = spawn_cron( $gmt_time ); 1005 1029 break 2; … … 1010 1034 return false; 1011 1035 } 1036 1012 1037 return count( $results ); 1013 1038 } … … 1214 1239 1215 1240 $cron['version'] = 2; 1216 $result = update_option( 'cron', $cron ); 1241 1242 $result = update_option( 'cron', $cron ); 1217 1243 1218 1244 if ( $wp_error && ! $result ) { … … 1238 1264 */ 1239 1265 function _upgrade_cron_array( $cron ) { 1240 if ( isset( $cron['version'] ) && 2 == $cron['version'] ) {1266 if ( isset( $cron['version'] ) && 2 === $cron['version'] ) { 1241 1267 return $cron; 1242 1268 } … … 1246 1272 foreach ( (array) $cron as $timestamp => $hooks ) { 1247 1273 foreach ( (array) $hooks as $hook => $args ) { 1248 $key = md5( serialize( $args['args'] ) ); 1274 $key = md5( serialize( $args['args'] ) ); 1275 1249 1276 $new_cron[ $timestamp ][ $hook ][ $key ] = $args; 1250 1277 } … … 1252 1279 1253 1280 $new_cron['version'] = 2; 1281 1254 1282 update_option( 'cron', $new_cron ); 1283 1255 1284 return $new_cron; 1256 1285 }
Note: See TracChangeset
for help on using the changeset viewer.