core_upgrade_preamble()
- Since
- 2.7.0
- Source
wp-admin/update-core.php:245
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
- Scaling
- Scales with input
- Instructions
- 37–88
- Plugin surface
- None
- Called by
- 0
Reads stored settings via get_site_option(), cached per request but not free on a cold cache.
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 115.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- optionnetwork option
get_site_option()one call below core_upgrade_preamble() - transienttransient
get_site_transient()one call below core_upgrade_preamble() - hookthird-party callbacks
do_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.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($value) | 37–39 | get_core_updates(), __(), dismissed_updates() |
!isset($value) | 39–45 | get_core_updates(), __(), __(), dismissed_updates() |
isset($value) && !version_compare() | 45–47 | get_core_updates(), version_compare(), __(), dismissed_updates() |
isset($value) && !version_compare() | 47–53 | get_core_updates(), version_compare(), __(), __(), dismissed_updates() |
!isset($value) | 53–63 | get_core_updates(), __(), explode(), __(), self_admin_url(), esc_url(), sprintf(), dismissed_updates() |
isset($value) && !version_compare() | 61–71 | get_core_updates(), version_compare(), __(), explode(), __(), self_admin_url(), esc_url(), sprintf(), dismissed_updates() |
isset($value) && version_compare() | 63–64 | get_core_updates(), version_compare(), _e(), __(), __(), __(), sprintf(), wp_admin_notice(), dismissed_updates() |
isset($value) && version_compare() | 65–70 | get_core_updates(), version_compare(), _e(), __(), __(), __(), sprintf(), wp_admin_notice(), __(), dismissed_updates() |
isset($value) && version_compare() | 79–88 | get_core_updates(), version_compare(), _e(), __(), __(), __(), sprintf(), wp_admin_notice(), explode(), __(), self_admin_url(), esc_url(), sprintf(), dismissed_updates() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 115 | 37–88 | 9 | |
| 8.5 | 115 | 37–88 | 9 | |
| 8.4 | 115 | 37–88 | 9 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 118 | 40–91 | 9 | |
| 8.2 | 118 | 40–91 | 9 | |
| 8.1 | 118 | 40–91 | 9 | |
| 7.4 | 118 | 40–91 | 9 |
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
- get_core_updates()Gets available core updates.
- _e()Displays translated text.
- __()Retrieves the translation of $text.
- wp_admin_notice()Outputs an admin notice.
- list_core_update()Lists available core updates.
- esc_url()Checks and cleans a URL.
- self_admin_url()Retrieves the URL to the admin area for either the current site or the network depending on context.
- dismissed_updates()Display dismissed updates.
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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.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.