wppaste
WordPress

WP_Site_Health::get_test_background_updates(): array

Since
5.2.0
Source
wp-admin/includes/class-wp-site-health.php:1730
Tests if WordPress can run automated background updates.

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

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
37–43

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 93.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_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.

WhenInstructionsCalls it makes
always37–43__(), __(), __(), label(), ->run_tests()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev9337–437
8.59337–437
8.49337–4372 fewer instructions than PHP 8.3
8.39540–467
8.29540–467
8.19540–467
7.49540–467

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

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 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.