WP_Site_Health::get_test_background_updates(): array
- Since
- 5.2.0
- Source
wp-admin/includes/class-wp-site-health.php:1705
Description
Background updates in WordPress are primarily used for minor releases and security updates.
It's important to either have these working, or be aware that they are intentionally disabled for whatever reason.
Compatibility
- WordPress
- since 5.2.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.
Return value
array- The test results.
Performance profile
How much work a call to WP_Site_Health::get_test_background_updates() 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
- Light
- Scaling
- Scales with input
- Instructions
- 37–43
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
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 93.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below WP_Site_Health::get_test_background_updates()
Further down the call graph this can also reach option, cache, serialize, query and transient. 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::get_test_background_updates() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 37–43 | __(), __(), __(), label(), ->run_tests() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 93 | 37–43 | 7 | |
| 8.5 | 93 | 37–43 | 7 | |
| 8.4 | 93 | 37–43 | 7 | 2 fewer instructions than PHP 8.3 |
| 8.3 | 95 | 40–46 | 7 | |
| 8.2 | 95 | 40–46 | 7 | |
| 8.1 | 95 | 40–46 | 7 | |
| 7.4 | 95 | 40–46 | 7 |
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 · 3
- __()Retrieves the translation of $text.
- esc_attr()Escaping for HTML attributes.
- WP_Site_Health_Auto_Updates::__construct()WP_Site_Health_Auto_Updates constructor.
Source code
public function get_test_background_updates() { $result = array( 'label' => __( 'Background updates are working' ), 'status' => 'good', 'badge' => array( 'label' => __( 'Security' ), 'color' => 'blue', ), 'description' => sprintf( '<p>%s</p>', __( 'Background updates ensure that WordPress can auto-update if a security update is released for the version you are currently using.' ) ), 'actions' => '', 'test' => 'background_updates', ); if ( ! class_exists( 'WP_Site_Health_Auto_Updates' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-site-health-auto-updates.php'; } /* * Run the auto-update tests in a separate class, * as there are many considerations to be made. */ $automatic_updates = new WP_Site_Health_Auto_Updates(); $tests = $automatic_updates->run_tests(); $output = '<ul>'; foreach ( $tests as $test ) { /* translators: Hidden accessibility text. */ $severity_string = __( 'Passed' ); if ( 'fail' === $test->severity ) { $result['label'] = __( 'Background updates are not working as expected' ); $result['status'] = 'critical'; /* translators: Hidden accessibility text. */ $severity_string = __( 'Error' ); } if ( 'warning' === $test->severity && 'good' === $result['status'] ) { $result['label'] = __( 'Background updates may not be working properly' ); $result['status'] = 'recommended'; /* translators: Hidden accessibility text. */ $severity_string = __( 'Warning' ); } $output .= sprintf( '<li><span class="dashicons %s"><span class="screen-reader-text">%s</span></span> %s</li>', esc_attr( $test->severity ), $severity_string, $test->description ); } $output .= '</ul>'; if ( 'good' !== $result['status'] ) { $result['description'] .= $output; } return $result; }Changelog
Introduced in 5.2.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 6.8.8 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.