upgrade_350()
- Since
- 3.5.0
- Source
wp-admin/includes/upgrade.php:1882
Compatibility
- WordPress
- since 3.5.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 upgrade_350() 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
- 9–61
- Plugin surface
- None
- Called by
- 1
Reaches the database via ->get_var().
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 70.
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 - sqldatabase query
->get_var()called directly - hookthird-party callbacks
apply_filters()one call below upgrade_350() - serializeserialisation
maybe_serialize()one call below upgrade_350() - cacheobject cache
wp_cache_get()one call below upgrade_350() - querycontent query
get_term()one call below upgrade_350()
Further down the call graph this can also reach transient. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 36 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost upgrade_350() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!$wp_current_db_version | 9 | none |
!wp_should_upgrade_global_tables() | 12 | wp_should_upgrade_global_tables() |
| always | 16 | get_term_by() |
!->get_var() | 17 | ->get_var() |
!wp_should_upgrade_global_tables() | 19 | wp_should_upgrade_global_tables(), get_term_by() |
!->get_var() && !wp_should_upgrade_global_tables() | 20 | ->get_var(), wp_should_upgrade_global_tables() |
->get_var() | 21 | ->get_var(), update_option() |
| always | 22 | get_term_by(), wp_delete_term() |
!->get_var() | 24 | ->get_var(), get_term_by() |
->get_var() && !wp_should_upgrade_global_tables() | 24 | ->get_var(), update_option(), wp_should_upgrade_global_tables() |
wp_should_upgrade_global_tables() | 24–25 | wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge() |
!wp_should_upgrade_global_tables() | 25 | wp_should_upgrade_global_tables(), get_term_by(), wp_delete_term() |
24 further outcomes, up to 61 instructions
$wp_current_db_version && !->get_var() && !wp_should_upgrade_global_tables() | 27 | ->get_var(), wp_should_upgrade_global_tables(), get_term_by() |
->get_var() | 28 | ->get_var(), update_option(), get_term_by() |
!->get_var() | 30 | ->get_var(), get_term_by(), wp_delete_term() |
$wp_current_db_version && ->get_var() && !wp_should_upgrade_global_tables() | 31 | ->get_var(), update_option(), wp_should_upgrade_global_tables(), get_term_by() |
wp_should_upgrade_global_tables() | 31–32 | wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), get_term_by() |
!->get_var() && wp_should_upgrade_global_tables() | 32–33 | ->get_var(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge() |
$wp_current_db_version && !->get_var() && !wp_should_upgrade_global_tables() | 33 | ->get_var(), wp_should_upgrade_global_tables(), get_term_by(), wp_delete_term() |
->get_var() | 34 | ->get_var(), update_option(), get_term_by(), wp_delete_term() |
wp_should_upgrade_global_tables() | 35–36 | wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), ->query() |
->get_var() && wp_should_upgrade_global_tables() | 36–37 | ->get_var(), update_option(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge() |
$wp_current_db_version && ->get_var() && !wp_should_upgrade_global_tables() | 37 | ->get_var(), update_option(), wp_should_upgrade_global_tables(), get_term_by(), wp_delete_term() |
wp_should_upgrade_global_tables() | 37–38 | wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), get_term_by(), wp_delete_term() |
$wp_current_db_version && !->get_var() && wp_should_upgrade_global_tables() | 39–40 | ->get_var(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), get_term_by() |
wp_should_upgrade_global_tables() | 42–43 | wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), ->query(), get_term_by() |
!->get_var() && wp_should_upgrade_global_tables() | 43–44 | ->get_var(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), ->query() |
$wp_current_db_version && ->get_var() && wp_should_upgrade_global_tables() | 43–44 | ->get_var(), update_option(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), get_term_by() |
$wp_current_db_version && !->get_var() && wp_should_upgrade_global_tables() | 45–46 | ->get_var(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), get_term_by(), wp_delete_term() |
->get_var() && wp_should_upgrade_global_tables() | 47–48 | ->get_var(), update_option(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), ->query() |
wp_should_upgrade_global_tables() | 48–49 | wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), ->query(), get_term_by(), wp_delete_term() |
$wp_current_db_version && ->get_var() && wp_should_upgrade_global_tables() | 49–50 | ->get_var(), update_option(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), get_term_by(), wp_delete_term() |
$wp_current_db_version && !->get_var() && wp_should_upgrade_global_tables() | 50–51 | ->get_var(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), ->query(), get_term_by() |
$wp_current_db_version && ->get_var() && wp_should_upgrade_global_tables() | 54–55 | ->get_var(), update_option(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), ->query(), get_term_by() |
$wp_current_db_version && !->get_var() && wp_should_upgrade_global_tables() | 56–57 | ->get_var(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), ->query(), get_term_by(), wp_delete_term() |
$wp_current_db_version && ->get_var() && wp_should_upgrade_global_tables() | 60–61 | ->get_var(), update_option(), wp_should_upgrade_global_tables(), get_post_types(), get_taxonomies(), array_merge(), ->query(), get_term_by(), wp_delete_term() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 70 | 9–61 | 10 | |
| 8.5 | 70 | 9–61 | 10 | |
| 8.4 | 70 | 9–61 | 10 | 9 fewer instructions than PHP 8.3 |
| 8.3 | 79 | 9–64 | 10 | |
| 8.2 | 79 | 9–64 | 10 | |
| 8.1 | 79 | 9–64 | 10 | |
| 7.4 | 79 | 9–64 | 10 |
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
- update_option()Updates the value of an option that was already added.
- wp_should_upgrade_global_tables()Determine if global tables should be upgraded.
- get_post_types()Gets a list of all registered post type objects.
- get_taxonomies()Retrieves a list of registered taxonomy names or objects.
- str_contains()Polyfill for `str_contains()` function added in PHP 8.0.
- get_term_by()Gets all term data from database by term field and data.
- wp_delete_term()Removes a term from the database.
Used by · 1
- upgrade_all()Functions to be called in installation and upgrade scripts.
Source code
function upgrade_350() { global $wp_current_db_version, $wpdb; if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) { update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options(). } if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { $meta_keys = array(); foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) { if ( str_contains( $name, '-' ) ) { $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page'; } } if ( $meta_keys ) { $meta_keys = implode( "', '", $meta_keys ); $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" ); } } if ( $wp_current_db_version < 22422 ) { $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ); if ( $term ) { wp_delete_term( $term->term_id, 'post_format' ); } }}Changelog
Introduced in 3.5.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 7.1.0 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.