upgrade_560()
- Since
- 5.6.0
- Source
wp-admin/includes/upgrade.php:2261
Compatibility
- WordPress
- since 5.6.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_560() 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
- Constant
- Instructions
- 11–61
- Plugin surface
- None
- Called by
- 1
Reaches the database via ->get_var().
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 61.
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 - transienttransient
delete_transient()called directly - sqldatabase query
->get_var()called directly - hookthird-party callbacks
apply_filters()one call below upgrade_560() - serializeserialisation
maybe_serialize()one call below upgrade_560() - cacheobject cache
wp_cache_get()one call below upgrade_560()
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 · 36 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost upgrade_560() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!$wp_current_db_version | 11 | none |
| always | 13 | save_mod_rewrite_rules() |
| always | 14 | delete_transient() |
| always | 16 | save_mod_rewrite_rules(), delete_transient() |
$post_category_exists === null | 25 | ->get_var(), update_option() |
empty($results) | 26 | ->prepare(), ->get_results() |
$post_category_exists === null | 27 | ->get_var(), update_option(), save_mod_rewrite_rules() |
empty($results) | 28 | save_mod_rewrite_rules(), ->prepare(), ->get_results() |
$post_category_exists === null | 28 | ->get_var(), update_option(), delete_transient() |
empty($results) | 29 | delete_transient(), ->prepare(), ->get_results() |
$post_category_exists === null | 30 | ->get_var(), update_option(), save_mod_rewrite_rules(), delete_transient() |
empty($results) | 31 | save_mod_rewrite_rules(), delete_transient(), ->prepare(), ->get_results() |
24 further outcomes, up to 61 instructions
$post_category_exists !== null | 32 | ->get_var(), ->query(), update_option() |
$post_category_exists !== null | 34 | ->get_var(), ->query(), update_option(), save_mod_rewrite_rules() |
!empty($results) | 35 | ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$post_category_exists !== null | 35 | ->get_var(), ->query(), update_option(), delete_transient() |
!empty($results) | 37 | save_mod_rewrite_rules(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$post_category_exists !== null | 37 | ->get_var(), ->query(), update_option(), save_mod_rewrite_rules(), delete_transient() |
!empty($results) | 38 | delete_transient(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$post_category_exists === null && empty($results) | 40 | ->get_var(), update_option(), ->prepare(), ->get_results() |
!empty($results) | 40 | save_mod_rewrite_rules(), delete_transient(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$post_category_exists === null && empty($results) | 42 | ->get_var(), update_option(), save_mod_rewrite_rules(), ->prepare(), ->get_results() |
$post_category_exists === null && empty($results) | 43 | ->get_var(), update_option(), delete_transient(), ->prepare(), ->get_results() |
$wp_current_db_version && $post_category_exists === null && empty($results) | 45 | ->get_var(), update_option(), save_mod_rewrite_rules(), delete_transient(), ->prepare(), ->get_results() |
$post_category_exists !== null && empty($results) | 47 | ->get_var(), ->query(), update_option(), ->prepare(), ->get_results() |
$post_category_exists === null && !empty($results) | 49 | ->get_var(), update_option(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$post_category_exists !== null && empty($results) | 49 | ->get_var(), ->query(), update_option(), save_mod_rewrite_rules(), ->prepare(), ->get_results() |
$post_category_exists !== null && empty($results) | 50 | ->get_var(), ->query(), update_option(), delete_transient(), ->prepare(), ->get_results() |
$post_category_exists === null && !empty($results) | 51 | ->get_var(), update_option(), save_mod_rewrite_rules(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$post_category_exists === null && !empty($results) | 52 | ->get_var(), update_option(), delete_transient(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$wp_current_db_version && $post_category_exists !== null && empty($results) | 52 | ->get_var(), ->query(), update_option(), save_mod_rewrite_rules(), delete_transient(), ->prepare(), ->get_results() |
$wp_current_db_version && $post_category_exists === null && !empty($results) | 54 | ->get_var(), update_option(), save_mod_rewrite_rules(), delete_transient(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$post_category_exists !== null && !empty($results) | 56 | ->get_var(), ->query(), update_option(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$post_category_exists !== null && !empty($results) | 58 | ->get_var(), ->query(), update_option(), save_mod_rewrite_rules(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$post_category_exists !== null && !empty($results) | 59 | ->get_var(), ->query(), update_option(), delete_transient(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
$wp_current_db_version && $post_category_exists !== null && !empty($results) | 61 | ->get_var(), ->query(), update_option(), save_mod_rewrite_rules(), delete_transient(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 61 instructions, 11–61 executed per call, 6 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 · 5
- update_option()Updates the value of an option that was already added.
- save_mod_rewrite_rules()Updates the htaccess file with the current rules if it is writable.
- delete_transient()Deletes a transient.
- get_main_network_id()Gets the main network ID.
- update_network_option()Updates the value of a network option that was already added.
Used by · 1
- upgrade_all()Functions to be called in installation and upgrade scripts.
Source code
function upgrade_560() { global $wp_current_db_version, $wpdb; if ( $wp_current_db_version < 49572 ) { /* * Clean up the `post_category` column removed from schema in version 2.8.0. * Its presence may conflict with `WP_Post::__get()`. */ $post_category_exists = $wpdb->get_var( "SHOW COLUMNS FROM $wpdb->posts LIKE 'post_category'" ); if ( ! is_null( $post_category_exists ) ) { $wpdb->query( "ALTER TABLE $wpdb->posts DROP COLUMN `post_category`" ); } /* * When upgrading from WP < 5.6.0 set the core major auto-updates option to `unset` by default. * This overrides the same option from populate_options() that is intended for new installs. * See https://core.trac.wordpress.org/ticket/51742. */ update_option( 'auto_update_core_major', 'unset' ); } if ( $wp_current_db_version < 49632 ) { /* * Regenerate the .htaccess file to add the `HTTP_AUTHORIZATION` rewrite rule. * See https://core.trac.wordpress.org/ticket/51723. */ save_mod_rewrite_rules(); } if ( $wp_current_db_version < 49735 ) { delete_transient( 'dirsize_cache' ); } if ( $wp_current_db_version < 49752 ) { $results = $wpdb->get_results( $wpdb->prepare( "SELECT 1 FROM {$wpdb->usermeta} WHERE meta_key = %s LIMIT 1", WP_Application_Passwords::USERMETA_KEY_APPLICATION_PASSWORDS ) ); if ( ! empty( $results ) ) { $network_id = get_main_network_id(); update_network_option( $network_id, WP_Application_Passwords::OPTION_KEY_IN_USE, 1 ); } }}Changelog
Introduced in 5.6.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.