WP_Site_Health::wp_cron_scheduled_check()
- Since
- 5.4.0
- Source
wp-admin/includes/class-wp-site-health.php:3354
Compatibility
- WordPress
- since 5.4.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Performance profile
How much work a call to WP_Site_Health::wp_cron_scheduled_check() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Expensive
- Scaling
- Scales with input
- Instructions
- 30–35
- Plugin surface
- None
- Called by
- 0
Reaches an outbound HTTP request via wp_remote_get().
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 177.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- httpoutbound HTTP request
wp_remote_get()called directly - transienttransient
set_transient()called directly - hookthird-party callbacks
apply_filters()one call below WP_Site_Health::wp_cron_scheduled_check() - cacheobject cache
wp_cache_set()one call below WP_Site_Health::wp_cron_scheduled_check() - optionoption read or write
get_option()one call below WP_Site_Health::wp_cron_scheduled_check()
Further down the call graph this can also reach serialize and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Site_Health::wp_cron_scheduled_check() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 30–35 | trailingslashit(), ::WP_Site_Health(), ->is_development_environment(), wp_json_encode(), set_transient() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 177 | 30–35 | 23 | |
| 8.5 | 177 | 30–35 | 23 | |
| 8.4 | 177 | 30–35 | 23 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 180 | 30–35 | 23 | |
| 8.2 | 180 | 30–35 | 23 | |
| 8.1 | 180 | 30–35 | 23 | |
| 7.4 | 180 | 30–35 | 23 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 14
- trailingslashit()Appends a trailing slash.
- wp_remote_get()Performs an HTTP request using the GET method and returns its response.
- wp_create_nonce()Creates a cryptographic token tied to a specific action, user, user session, and window of time.
- wp_remote_post()Performs an HTTP request using the POST method and returns its response.
- admin_url()Retrieves the URL to the admin area for the current site.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- wp_remote_retrieve_response_code()Retrieves only the response code from the raw response.
- wp_remote_retrieve_body()Retrieves only the body from the raw response.
- __()Retrieves the translation of $text.
- set_transient()Sets/updates the value of a transient.
- wp_json_encode()Encodes a variable into JSON, with some confidence checks.
- WP_Site_Health::get_tests()Returns a set of tests that belong to the site status page.
Show all 14
- WP_Site_Health::is_development_environment()Checks if the current environment type is set to 'development' or 'local'.
- WP_Site_Health::perform_test()Runs a Site Health test directly.
Source code
public function wp_cron_scheduled_check() { // Bootstrap wp-admin, as WP_Cron doesn't do this for us. require_once trailingslashit( ABSPATH ) . 'wp-admin/includes/admin.php'; $tests = WP_Site_Health::get_tests(); $results = array(); $site_status = array( 'good' => 0, 'recommended' => 0, 'critical' => 0, ); // Don't run https test on development environments. if ( $this->is_development_environment() ) { unset( $tests['async']['https_status'] ); } foreach ( $tests['direct'] as $test ) { if ( ! empty( $test['skip_cron'] ) ) { continue; } if ( is_string( $test['test'] ) ) { $test_function = sprintf( 'get_test_%s', $test['test'] ); if ( method_exists( $this, $test_function ) && is_callable( array( $this, $test_function ) ) ) { $results[] = $this->perform_test( array( $this, $test_function ) ); continue; } } if ( is_callable( $test['test'] ) ) { $results[] = $this->perform_test( $test['test'] ); } } foreach ( $tests['async'] as $test ) { if ( ! empty( $test['skip_cron'] ) ) { continue; } // Local endpoints may require authentication, so asynchronous tests can pass a direct test runner as well. if ( ! empty( $test['async_direct_test'] ) && is_callable( $test['async_direct_test'] ) ) { // This test is callable, do so and continue to the next asynchronous check. $results[] = $this->perform_test( $test['async_direct_test'] ); continue; } if ( is_string( $test['test'] ) ) { // Check if this test has a REST API endpoint. if ( isset( $test['has_rest'] ) && $test['has_rest'] ) { $result_fetch = wp_remote_get( $test['test'], array( 'body' => array( '_wpnonce' => wp_create_nonce( 'wp_rest' ), ), ) ); } else { $result_fetch = wp_remote_post( admin_url( 'admin-ajax.php' ), array( 'body' => array( 'action' => $test['test'], '_wpnonce' => wp_create_nonce( 'health-check-site-status' ), ), ) ); } if ( ! is_wp_error( $result_fetch ) && 200 === wp_remote_retrieve_response_code( $result_fetch ) ) { $result = json_decode( wp_remote_retrieve_body( $result_fetch ), true ); } else { $result = false;Changelog
Introduced in 5.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-admin/includes/class-wp-site-health.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.