wppaste
WordPress

core_upgrade_preamble()

Since
2.7.0
Source
wp-admin/update-core.php:245
Display upgrade WordPress for downloading latest or upgrading automatically form.

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.

Performance profile

How much work a call to core_upgrade_preamble() 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 stored settings via get_site_option(), cached per request but not free on a cold cache.

Scaling
Scales with input

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

Instructions
37–88

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

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

  • optionnetwork optionget_site_option()one call below core_upgrade_preamble()
  • transienttransientget_site_transient()one call below core_upgrade_preamble()
  • hookthird-party callbacksdo_action()one call below core_upgrade_preamble()

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 · 9 distinct outcomes

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

WhenInstructionsCalls it makes
!isset($value)37–39get_core_updates(), __(), dismissed_updates()
!isset($value)39–45get_core_updates(), __(), __(), dismissed_updates()
isset($value) && !version_compare()45–47get_core_updates(), version_compare(), __(), dismissed_updates()
isset($value) && !version_compare()47–53get_core_updates(), version_compare(), __(), __(), dismissed_updates()
!isset($value)53–63get_core_updates(), __(), explode(), __(), self_admin_url(), esc_url(), sprintf(), dismissed_updates()
isset($value) && !version_compare()61–71get_core_updates(), version_compare(), __(), explode(), __(), self_admin_url(), esc_url(), sprintf(), dismissed_updates()
isset($value) && version_compare()63–64get_core_updates(), version_compare(), _e(), __(), __(), __(), sprintf(), wp_admin_notice(), dismissed_updates()
isset($value) && version_compare()65–70get_core_updates(), version_compare(), _e(), __(), __(), __(), sprintf(), wp_admin_notice(), __(), dismissed_updates()
isset($value) && version_compare()79–88get_core_updates(), version_compare(), _e(), __(), __(), __(), sprintf(), wp_admin_notice(), explode(), __(), self_admin_url(), esc_url(), sprintf(), dismissed_updates()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev11537–889
8.511537–889
8.411537–8893 fewer instructions than PHP 8.3
8.311840–919
8.211840–919
8.111840–919
7.411840–919

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

Source code

function core_upgrade_preamble() {	$updates = get_core_updates(); 	// Include an unmodified $wp_version.	require ABSPATH . WPINC . '/version.php'; 	$is_development_version = preg_match( '/alpha|beta|RC/', $wp_version ); 	if ( isset( $updates[0]->version ) && version_compare( $updates[0]->version, $wp_version, '>' ) ) {		echo '<h2 class="response">';		_e( 'An updated version of WordPress is available.' );		echo '</h2>'; 		$message = sprintf(			/* translators: 1: Documentation on WordPress backups, 2: Documentation on updating WordPress. */			__( '<strong>Important:</strong> Before updating, please <a href="%1$s">back up your database and files</a>. For help with updates, visit the <a href="%2$s">Updating WordPress</a> documentation page.' ),			__( 'https://developer.wordpress.org/advanced-administration/security/backup/' ),			__( 'https://wordpress.org/documentation/article/updating-wordpress/' )		);		wp_admin_notice(			$message,			array(				'type'               => 'warning',				'additional_classes' => array( 'inline' ),			)		);	} elseif ( $is_development_version ) {		echo '<h2 class="response">' . __( 'You are using a development version of WordPress.' ) . '</h2>';	} else {		echo '<h2 class="response">' . __( 'You have the latest version of WordPress.' ) . '</h2>';	} 	echo '<ul class="core-updates">';	foreach ( (array) $updates as $update ) {		echo '<li>';		list_core_update( $update );		echo '</li>';	}	echo '</ul>'; 	// Don't show the maintenance mode notice when we are only showing a single re-install option.	if ( $updates && ( count( $updates ) > 1 || 'latest' !== $updates[0]->response ) ) {		echo '<p>' . __( 'While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, this mode will be deactivated.' ) . '</p>';	} elseif ( ! $updates ) {		list( $normalized_version ) = explode( '-', $wp_version );		echo '<p>' . sprintf(			/* translators: 1: URL to About screen, 2: WordPress version. */			__( '<a href="%1$s">Learn more about WordPress %2$s</a>.' ),			esc_url( self_admin_url( 'about.php' ) ),			$normalized_version		) . '</p>';	} 	dismissed_updates();}

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.9.7 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.