upgrade_all()
- Since
- 1.0.1
- Source
wp-admin/includes/upgrade.php:715
Description
Contains conditional checks to determine which upgrade scripts to run, based on database version and WP version being updated-to.
Compatibility
- WordPress
- since 1.0.1
- PHP
- 7.4–8.6-dev
- 6.7.10
- 6.8.11
- 6.9.10
- 7.0.7
- 7.1.3
Present in every tracked release (6.7.10 to 7.1.3), and compiles on PHP 7.4 through 8.6-dev.
Performance profile
How much work a call to upgrade_all() 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
- 13–36
- Plugin surface
- None
- Called by
- 1
Reads stored settings via update_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 226.
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
- optionoption read or write
update_option()called directly - serializeserialisation
maybe_unserialize()one call below upgrade_all() - hookthird-party callbacks
do_action()one call below upgrade_all() - transienttransient
delete_transient()one call below upgrade_all() - cacheobject cache
wp_cache_get()one call below upgrade_all()
Further down the call graph this can also reach query. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost upgrade_all() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!->next_token() | 13 | ->set_bookmark(), ->next_token(), ->get_tag() |
!->next_token() && !->is_tag_closer() | 16 | ->set_bookmark(), ->next_token(), ->get_tag(), ->is_tag_closer() |
->next_token() | 17 | ->set_bookmark(), ->next_token(), ->get_token_name(), ->get_tag() |
->next_token() && !->is_tag_closer() | 20 | ->set_bookmark(), ->next_token(), ->get_token_name(), ->get_tag(), ->is_tag_closer() |
!->next_token() && ->is_tag_closer() | 32 | ->set_bookmark(), ->next_token(), ->get_tag(), ->is_tag_closer(), ->set_bookmark() |
->next_token() && ->is_tag_closer() | 36 | ->set_bookmark(), ->next_token(), ->get_token_name(), ->get_tag(), ->is_tag_closer(), ->set_bookmark() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 226 instructions, 13–36 executed per call, 44 branches. The work does not change between versions.
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 · 45
- __get_option()Utility version of get_option that is private to installation/upgrade.
- upgrade_230_options_table()Remove old options from the database.
- populate_options()Create WordPress options and set the default values.
- upgrade_100()Execute changes made in WordPress 1.0.
- upgrade_101()Execute changes made in WordPress 1.0.1.
- upgrade_110()Execute changes made in WordPress 1.2.
- upgrade_130()Execute changes made in WordPress 1.5.
- upgrade_160()Execute changes made in WordPress 2.0.
- upgrade_210()Execute changes made in WordPress 2.1.
- upgrade_old_slugs()Upgrade old slugs made in version 2.2.
- upgrade_230()Execute changes made in WordPress 2.3.
- upgrade_230_old_tables()Remove old categories, link2cat, and post2cat database tables.
Show all 45
- upgrade_250()Execute changes made in WordPress 2.5.0.
- upgrade_252()Execute changes made in WordPress 2.5.2.
- upgrade_260()Execute changes made in WordPress 2.6.
- upgrade_270()Execute changes made in WordPress 2.7.
- upgrade_280()Execute changes made in WordPress 2.8.
- upgrade_290()Execute changes made in WordPress 2.9.
- upgrade_300()Execute changes made in WordPress 3.0.
- upgrade_330()Execute changes made in WordPress 3.3.
- upgrade_340()Execute changes made in WordPress 3.4.
- upgrade_350()Execute changes made in WordPress 3.5.
- upgrade_370()Execute changes made in WordPress 3.7.
- upgrade_372()Execute changes made in WordPress 3.7.2.
- upgrade_380()Execute changes made in WordPress 3.8.0.
- upgrade_400()Execute changes made in WordPress 4.0.0.
- upgrade_430()Executes changes made in WordPress 4.3.0.
- upgrade_431()Executes changes made in WordPress 4.3.1.
- upgrade_440()Executes changes made in WordPress 4.4.0.
- upgrade_450()Executes changes made in WordPress 4.5.0.
- upgrade_460()Executes changes made in WordPress 4.6.0.
- upgrade_510()Executes changes made in WordPress 5.1.0.
- upgrade_530()Executes changes made in WordPress 5.3.0.
- upgrade_550()Executes changes made in WordPress 5.5.0.
- upgrade_560()Executes changes made in WordPress 5.6.0.
- upgrade_590()Executes changes made in WordPress 5.9.0.
- upgrade_600()Executes changes made in WordPress 6.0.0.
- upgrade_630()Executes changes made in WordPress 6.3.0.
- upgrade_640()Executes changes made in WordPress 6.4.0.
- upgrade_650()Executes changes made in WordPress 6.5.0.
- upgrade_670()Executes changes made in WordPress 6.7.0.
- upgrade_682()Executes changes made in WordPress 6.8.2.
- maybe_disable_link_manager()Disables the Link Manager on upgrade if, at the time of upgrade, no links exist in the DB.
- maybe_disable_automattic_widgets()Disables the Automattic widgets plugin, which was merged into core.
- update_option()Updates the value of an option that was already added.
Used by · 1
- wp_upgrade()Runs WordPress Upgrade functions.
Source code
function upgrade_all() { global $wp_current_db_version, $wp_db_version; $wp_current_db_version = (int) __get_option( 'db_version' ); // We are up to date. Nothing to do. if ( $wp_db_version === $wp_current_db_version ) { return; } // If the version is not set in the DB, try to guess the version. if ( empty( $wp_current_db_version ) ) { $wp_current_db_version = 0; // If the template option exists, we have 1.5. $template = __get_option( 'template' ); if ( ! empty( $template ) ) { $wp_current_db_version = 2541; } } if ( $wp_current_db_version < 6039 ) { upgrade_230_options_table(); } populate_options(); if ( $wp_current_db_version < 2541 ) { upgrade_100(); upgrade_101(); upgrade_110(); upgrade_130(); } if ( $wp_current_db_version < 3308 ) { upgrade_160(); } if ( $wp_current_db_version < 4772 ) { upgrade_210(); } if ( $wp_current_db_version < 4351 ) { upgrade_old_slugs(); } if ( $wp_current_db_version < 5539 ) { upgrade_230(); } if ( $wp_current_db_version < 6124 ) { upgrade_230_old_tables(); } if ( $wp_current_db_version < 7499 ) { upgrade_250(); } if ( $wp_current_db_version < 7935 ) { upgrade_252(); } if ( $wp_current_db_version < 8201 ) { upgrade_260(); } if ( $wp_current_db_version < 8989 ) { upgrade_270(); } if ( $wp_current_db_version < 10360 ) { upgrade_280(); } if ( $wp_current_db_version < 11958 ) { upgrade_290(); } if ( $wp_current_db_version < 15260 ) { upgrade_300();Changelog
Introduced in 1.0.1. Unchanged from 6.7.10 through 7.1.3.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.10 tag, from
src/wp-admin/includes/upgrade.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.