WP_Automatic_Updater::after_core_update( object $update_result )
- Since
- 3.7.0
- Source
wp-admin/includes/class-wp-automatic-updater.php:797
Compatibility
- WordPress
- since 3.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
$update_resultobject- The result of the core update. Includes the update offer and result.
Performance profile
How much work a call to WP_Automatic_Updater::after_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
- Moderate
- Scaling
- Constant
- Instructions
- 15–92
- Plugin surface
- None
- Called by
- 1
Reads stored settings via update_site_option(), cached per request but not free on a cold cache.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 134.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- optionnetwork option
update_site_option()called directly - hookthird-party callbacks
do_action()one call below WP_Automatic_Updater::after_core_update()
Further down the call graph this can also reach serialize, cache, 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 · 37 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Automatic_Updater::after_core_update() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!is_wp_error() | 15 | wp_get_wp_version(), is_wp_error(), ->send_email() |
is_wp_error() && !isset($rollback_result) | 43–48 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), time(), update_site_option(), ->send_email() |
is_wp_error() && !$error_code | 45–53 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), get_site_option(), ->get_error_data(), time(), attempted() |
is_wp_error() | 49–64 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted() |
is_wp_error() && !$error_code | 50–58 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
is_wp_error() && isset($rollback_result) | 51–56 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), time(), ->get_error_code(), ->get_error_data(), update_site_option(), ->send_email() |
is_wp_error() | 54–69 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
$error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" && !isset($rollback_result) | 55–56 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), time(), update_site_option(), ->send_email() |
$error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" | 57–61 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), get_site_option(), ->get_error_data(), time(), attempted() |
is_wp_error() && $error_code && get_site_option() | 58–68 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), get_site_option(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted() |
is_wp_error() && $error_code && !get_site_option() | 58–66 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), ->get_error_data(), time(), attempted() |
is_wp_error() && $error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" && !isset($rollback_result) | 58 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), ->get_error_data(), time(), update_site_option(), ->send_email() |
25 further outcomes, up to 92 instructions
is_wp_error() && $error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" | 60–63 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), get_site_option(), ->get_error_data(), time(), attempted() |
$error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" | 61–72 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted() |
$error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" | 62–66 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
is_wp_error() && $error_code && get_site_option() | 63–73 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), get_site_option(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
is_wp_error() && $error_code && !get_site_option() | 63–71 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
$error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" && isset($rollback_result) | 63–64 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), time(), ->get_error_code(), ->get_error_data(), update_site_option(), ->send_email() |
is_wp_error() && $error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" | 64–74 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted() |
is_wp_error() && $error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" | 65–68 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
$error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" | 66–77 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
is_wp_error() && $error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" && isset($rollback_result) | 66 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), ->get_error_data(), time(), ->get_error_code(), ->get_error_data(), update_site_option(), ->send_email() |
is_wp_error() && $error_code && !get_site_option() | 67–77 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted() |
is_wp_error() && $error_code !== "disk_full" && !$error_code && $error_code === "rollback_was_required" | 69–79 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
$error_code !== "disk_full" && $error_code === "rollback_was_required" && get_site_option() | 70–76 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), get_site_option(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted() |
$error_code !== "disk_full" && $error_code === "rollback_was_required" && !get_site_option() | 70–74 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), ->get_error_data(), time(), attempted() |
is_wp_error() && $error_code && !get_site_option() | 72–82 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
is_wp_error() && $error_code !== "disk_full" && $error_code === "rollback_was_required" && get_site_option() | 73–78 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), get_site_option(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted() |
is_wp_error() && $error_code !== "disk_full" && $error_code === "rollback_was_required" && !get_site_option() | 73–76 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), ->get_error_data(), time(), attempted() |
$error_code !== "disk_full" && $error_code === "rollback_was_required" && get_site_option() | 75–81 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), get_site_option(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
$error_code !== "disk_full" && $error_code === "rollback_was_required" && !get_site_option() | 75–79 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
is_wp_error() && $error_code !== "disk_full" && $error_code === "rollback_was_required" && get_site_option() | 78–83 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), get_site_option(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
is_wp_error() && $error_code !== "disk_full" && $error_code === "rollback_was_required" && !get_site_option() | 78–81 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
$error_code !== "disk_full" && $error_code === "rollback_was_required" && !get_site_option() | 79–85 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted() |
is_wp_error() && $error_code !== "disk_full" && $error_code === "rollback_was_required" && !get_site_option() | 82–87 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted() |
$error_code !== "disk_full" && $error_code === "rollback_was_required" && !get_site_option() | 84–90 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
is_wp_error() && $error_code !== "disk_full" && $error_code === "rollback_was_required" && !get_site_option() | 87–92 | wp_get_wp_version(), is_wp_error(), ->get_error_code(), ->get_error_data(), is_wp_error(), ->get_error_data(), get_site_option(), time(), wp_schedule_single_event(), get_site_option(), get_site_option(), ->get_error_data(), time(), attempted(), ->send_email() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 134 | 15–92 | 15 | |
| 8.5 | 134 | 15–92 | 15 | |
| 8.4 | 134 | 15–92 | 15 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 140 | 15–96 | 15 | |
| 8.2 | 140 | 15–96 | 15 | |
| 8.1 | 140 | 15–96 | 15 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 141 | 15–97 | 15 |
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 · 7
- wp_get_wp_version()Returns the current WordPress version.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- update_site_option()Updates the value of an option that was already added for the current network.
- get_site_option()Retrieve an option value for the current network based on name of option.
- wp_schedule_single_event()Schedules an event to run only once.
- WP_Automatic_Updater::send_email()Sends an email upon the completion or failure of a background core update.
Used by · 1
- WP_Automatic_Updater::run()Kicks off the background update process, looping through all pending updates.
Source code
protected function after_core_update( $update_result ) { $wp_version = wp_get_wp_version(); $core_update = $update_result->item; $result = $update_result->result; if ( ! is_wp_error( $result ) ) { $this->send_email( 'success', $core_update ); return; } $error_code = $result->get_error_code(); /* * Any of these WP_Error codes are critical failures, as in they occurred after we started to copy core files. * We should not try to perform a background update again until there is a successful one-click update performed by the user. */ $critical = false; if ( 'disk_full' === $error_code || str_contains( $error_code, '__copy_dir' ) ) { $critical = true; } elseif ( 'rollback_was_required' === $error_code && is_wp_error( $result->get_error_data()->rollback ) ) { // A rollback is only critical if it failed too. $critical = true; $rollback_result = $result->get_error_data()->rollback; } elseif ( str_contains( $error_code, 'do_rollback' ) ) { $critical = true; } if ( $critical ) { $critical_data = array( 'attempted' => $core_update->current, 'current' => $wp_version, 'error_code' => $error_code, 'error_data' => $result->get_error_data(), 'timestamp' => time(), 'critical' => true, ); if ( isset( $rollback_result ) ) { $critical_data['rollback_code'] = $rollback_result->get_error_code(); $critical_data['rollback_data'] = $rollback_result->get_error_data(); } update_site_option( 'auto_core_update_failed', $critical_data ); $this->send_email( 'critical', $core_update, $result ); return; } /* * Any other WP_Error code (like download_failed or files_not_writable) occurs before * we tried to copy over core files. Thus, the failures are early and graceful. * * We should avoid trying to perform a background update again for the same version. * But we can try again if another version is released. * * For certain 'transient' failures, like download_failed, we should allow retries. * In fact, let's schedule a special update for an hour from now. (It's possible * the issue could actually be on WordPress.org's side.) If that one fails, then email. */ $send = true; $transient_failures = array( 'incompatible_archive', 'download_failed', 'insane_distro', 'locked' ); if ( in_array( $error_code, $transient_failures, true ) && ! get_site_option( 'auto_core_update_failed' ) ) { wp_schedule_single_event( time() + HOUR_IN_SECONDS, 'wp_maybe_auto_update' ); $send = false; } $notified = get_site_option( 'auto_core_update_notified' ); // Don't notify if we've already notified the same email address of the same version of the same notification type. if ( $notified && 'fail' === $notified['type'] && get_site_option( 'admin_email' ) === $notified['email'] && $notified['version'] === $core_update->current ) { $send = false; } update_site_option( 'auto_core_update_failed', array( 'attempted' => $core_update->current, 'current' => $wp_version,Changelog
Introduced in 3.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.9.7 tag, from
src/wp-admin/includes/class-wp-automatic-updater.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.