Changeset 60925 for trunk/src/wp-includes/cron.php
- Timestamp:
- 10/12/2025 09:40:08 PM (8 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/cron.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/cron.php
r60653 r60925 973 973 974 974 /** 975 * Registers _wp_cron() to run on the {@see 'wp_loaded'} action. 976 * 977 * If the {@see 'wp_loaded'} action has already fired, this function calls 978 * _wp_cron() directly. 979 * 980 * Warning: This function may return Boolean FALSE, but may also return a non-Boolean 981 * value which evaluates to FALSE. For information about casting to booleans see the 982 * {@link https://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use 983 * the `===` operator for testing the return value of this function. 975 * Registers _wp_cron() to run on the {@see 'shutdown'} action. 976 * 977 * The spawn_cron() function attempts to make a non-blocking loopback request to `wp-cron.php` (when alternative 978 * cron is not being used). However, the wp_remote_post() function does not always respect the `timeout` and 979 * `blocking` parameters. A timeout of `0.01` may end up taking 1 second. When this runs at the {@see 'wp_loaded'} 980 * action, it increases the Time To First Byte (TTFB) since the HTML cannot be sent while waiting for the cron request 981 * to initiate. Moving the spawning of cron to the {@see 'shutdown'} hook allows for the server to flush the HTML document to 982 * the browser while waiting for the request. 984 983 * 985 984 * @since 2.1.0 986 985 * @since 5.1.0 Return value added to indicate success or failure. 987 986 * @since 5.7.0 Functionality moved to _wp_cron() to which this becomes a wrapper. 988 * 989 * @return false|int|void On success an integer indicating number of events spawned (0 indicates no 990 * events needed to be spawned), false if spawning fails for one or more events or 991 * void if the function registered _wp_cron() to run on the action. 992 */ 993 function wp_cron() { 994 if ( did_action( 'wp_loaded' ) ) { 995 return _wp_cron(); 996 } 997 998 add_action( 'wp_loaded', '_wp_cron', 20 ); 987 * @since 6.9.0 The _wp_cron() callback is moved from {@see 'wp_loaded'} to the {@see 'shutdown'} action; the function always returns void. 988 */ 989 function wp_cron(): void { 990 if ( doing_action( 'shutdown' ) ) { 991 _wp_cron(); 992 } else { 993 add_action( 'shutdown', '_wp_cron' ); 994 } 999 995 } 1000 996
Note: See TracChangeset
for help on using the changeset viewer.