wppaste
WordPress

upgrade_560()

Since
5.6.0
Source
wp-admin/includes/upgrade.php:2261
Executes changes made in WordPress 5.6.0.

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

Reaches the database via ->get_var().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
11–61

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 61.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • optionoption read or writeupdate_option()called directly
  • transienttransientdelete_transient()called directly
  • sqldatabase query->get_var()called directly
  • hookthird-party callbacksapply_filters()one call below upgrade_560()
  • serializeserialisationmaybe_serialize()one call below upgrade_560()
  • cacheobject cachewp_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.

WhenInstructionsCalls it makes
!$wp_current_db_version11none
always13save_mod_rewrite_rules()
always14delete_transient()
always16save_mod_rewrite_rules(), delete_transient()
$post_category_exists === null25->get_var(), update_option()
empty($results)26->prepare(), ->get_results()
$post_category_exists === null27->get_var(), update_option(), save_mod_rewrite_rules()
empty($results)28save_mod_rewrite_rules(), ->prepare(), ->get_results()
$post_category_exists === null28->get_var(), update_option(), delete_transient()
empty($results)29delete_transient(), ->prepare(), ->get_results()
$post_category_exists === null30->get_var(), update_option(), save_mod_rewrite_rules(), delete_transient()
empty($results)31save_mod_rewrite_rules(), delete_transient(), ->prepare(), ->get_results()
24 further outcomes, up to 61 instructions
$post_category_exists !== null32->get_var(), ->query(), update_option()
$post_category_exists !== null34->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 !== null35->get_var(), ->query(), update_option(), delete_transient()
!empty($results)37save_mod_rewrite_rules(), ->prepare(), ->get_results(), get_main_network_id(), update_network_option()
$post_category_exists !== null37->get_var(), ->query(), update_option(), save_mod_rewrite_rules(), delete_transient()
!empty($results)38delete_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)40save_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

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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.