wppaste
WordPress

list_core_update( object $update )

Since
2.7.0
Source
wp-admin/update-core.php:36
Lists available core updates.

Compatibility

WordPress
since 2.7.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.

Parameters

$updateobject

Performance profile

How much work a call to list_core_update() 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
Heavy

Reads or writes the filesystem via file_exists().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
155–218

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
2

2 places in core call this, so the cost is paid more often than your own code shows.

What it touches

  • filesystemfilesystem accessfile_exists()called directly
  • hookthird-party callbacksapply_filters()one call below list_core_update()
  • optionnetwork optionget_site_option()one call below list_core_update()
  • transienttransientget_site_transient()one call below list_core_update()

Further down the call graph this can also reach cache, 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 · 16 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost list_core_update() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!isset($update) && !file_exists()155–168wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr()
!isset($update) && !file_exists()159–178wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), get_locale()
!isset($update) && !file_exists()161–172wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), __()
!isset($update) && !file_exists()162–180wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), submit_button()
!isset($update) && !file_exists()166–190wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), submit_button(), get_locale()
!isset($update) && !file_exists()167–182wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), __(), submit_button()
!isset($update) && !file_exists()168–184wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), submit_button(), __()
!isset($update) && !file_exists()171–192wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), __(), submit_button(), get_locale()
!isset($update) && !file_exists()173–186wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), __(), submit_button(), __()
!isset($update) && !file_exists()174–193wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), submit_button(), __(), submit_button()
!isset($update) && !file_exists()178–203wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), submit_button(), __(), submit_button(), get_locale()
!isset($update) && !file_exists() && $wp_version === false179–193wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), get_locale(), __(), sprintf()
4 further outcomes, up to 218 instructions
!isset($update) && !file_exists()180–197wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), submit_button(), __(), submit_button(), __()
!isset($update) && !file_exists() && $wp_version === false186–205wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), submit_button(), get_locale(), __(), sprintf()
!isset($update) && !file_exists() && $wp_version === false191–207wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), __(), submit_button(), get_locale(), __(), sprintf()
!isset($update) && !file_exists() && $wp_version === false198–218wp_get_wp_version(), get_locale(), ->db_version(), __(), sprintf(), version_compare(), file_exists(), version_compare(), __(), esc_url(), sanitize_title(), sprintf(), __(), wp_get_update_php_url(), esc_url(), sprintf(), wp_get_update_php_annotation(), __(), sprintf(), esc_url(), wp_nonce_field(), esc_attr(), esc_attr(), submit_button(), __(), submit_button(), get_locale(), __(), sprintf()

This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev358155–21837
8.5358155–21837
8.4358155–218378 fewer instructions than PHP 8.3
8.3366161–22437
8.2366161–22437
8.1366161–224371 fewer instruction than PHP 7.4
7.4367161–22537

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 · 11

Used by · 2

Source code

function list_core_update( $update ) {	global $wp_local_package, $wpdb;	static $first_pass = true; 	$wp_version     = wp_get_wp_version();	$version_string = sprintf( '%s&ndash;%s', $update->current, get_locale() ); 	if ( 'en_US' === $update->locale && 'en_US' === get_locale() ) {		$version_string = $update->current;	} elseif ( 'en_US' === $update->locale && $update->packages->partial && $wp_version === $update->partial_version ) {		$updates = get_core_updates();		if ( $updates && 1 === count( $updates ) ) {			// If the only available update is a partial builds, it doesn't need a language-specific version string.			$version_string = $update->current;		}	} elseif ( 'en_US' === $update->locale && 'en_US' !== get_locale() ) {		$version_string = sprintf( '%s&ndash;%s', $update->current, $update->locale );	} 	$current = false;	if ( ! isset( $update->response ) || 'latest' === $update->response ) {		$current = true;	} 	$message       = '';	$form_action   = 'update-core.php?action=do-core-upgrade';	$php_version   = PHP_VERSION;	$mysql_version = $wpdb->db_version();	$show_buttons  = true; 	// Nightly build versions have two hyphens and a commit number.	if ( preg_match( '/-\w+-\d+/', $update->current ) ) {		// Retrieve the major version number.		preg_match( '/^\d+.\d+/', $update->current, $update_major );		/* translators: %s: WordPress version. */		$submit = sprintf( __( 'Update to latest %s nightly' ), $update_major[0] );	} else {		/* translators: %s: WordPress version. */		$submit = sprintf( __( 'Update to version %s' ), $version_string );	} 	if ( 'development' === $update->response ) {		$message = __( 'You can update to the latest nightly build manually:' );	} else {		if ( $current ) {			/* translators: %s: WordPress version. */			$submit      = sprintf( __( 'Re-install version %s' ), $version_string );			$form_action = 'update-core.php?action=do-core-reinstall';		} else {			$php_compat = version_compare( $php_version, $update->php_version, '>=' );			if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {				$mysql_compat = true;			} else {				$mysql_compat = version_compare( $mysql_version, $update->mysql_version, '>=' );			} 			$version_url = sprintf(				/* translators: %s: WordPress version. */				esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ),				sanitize_title( $update->current )			); 			$php_update_message = '</p><p>' . sprintf(				/* translators: %s: URL to Update PHP page. */				__( '<a href="%s">Learn more about updating PHP</a>.' ),				esc_url( wp_get_update_php_url() )			); 			$annotation = wp_get_update_php_annotation(); 			if ( $annotation ) {				$php_update_message .= '</p><p><em>' . $annotation . '</em>';			} 			if ( ! $mysql_compat && ! $php_compat ) {				$message = sprintf(					/* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number. */					__( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ),					$version_url,					$update->current,

Changelog

Introduced in 2.7.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 6.8.8 tag, from src/wp-admin/update-core.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.