wp_upgrade

The timeline below displays how wordpress function wp_upgrade has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Runs WordPress Upgrade functions.
 *
 * Upgrades the database if needed during a site update.
 *
 * @since 2.1.0
 *
 * @global int  $wp_current_db_version The old (current) database version.
 * @global int  $wp_db_version         The new database version.
 */
function wp_upgrade()
{
    global $wp_current_db_version, $wp_db_version;
    $wp_current_db_version = __get_option('db_version');
    // We are up to date. Nothing to do.
    if ($wp_db_version == $wp_current_db_version) {
        return;
    }
    if (!is_blog_installed()) {
        return;
    }
    wp_check_mysql_version();
    wp_cache_flush();
    pre_schema_upgrade();
    make_db_current_silent();
    upgrade_all();
    if (is_multisite() && is_main_site()) {
        upgrade_network();
    }
    wp_cache_flush();
    if (is_multisite()) {
        update_site_meta(get_current_blog_id(), 'db_version', $wp_db_version);
        update_site_meta(get_current_blog_id(), 'db_last_updated', microtime());
    }
    delete_transient('wp_core_block_css_files');
    /**
     * Fires after a site is fully upgraded.
     *
     * @since 3.9.0
     *
     * @param int $wp_db_version         The new $wp_db_version.
     * @param int $wp_current_db_version The old (current) $wp_db_version.
     */
    do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
}

WordPress Version: 6.3

/**
 * Runs WordPress Upgrade functions.
 *
 * Upgrades the database if needed during a site update.
 *
 * @since 2.1.0
 *
 * @global int  $wp_current_db_version The old (current) database version.
 * @global int  $wp_db_version         The new database version.
 * @global wpdb $wpdb                  WordPress database abstraction object.
 */
function wp_upgrade()
{
    global $wp_current_db_version, $wp_db_version, $wpdb;
    $wp_current_db_version = __get_option('db_version');
    // We are up to date. Nothing to do.
    if ($wp_db_version == $wp_current_db_version) {
        return;
    }
    if (!is_blog_installed()) {
        return;
    }
    wp_check_mysql_version();
    wp_cache_flush();
    pre_schema_upgrade();
    make_db_current_silent();
    upgrade_all();
    if (is_multisite() && is_main_site()) {
        upgrade_network();
    }
    wp_cache_flush();
    if (is_multisite()) {
        update_site_meta(get_current_blog_id(), 'db_version', $wp_db_version);
        update_site_meta(get_current_blog_id(), 'db_last_updated', microtime());
    }
    delete_transient('wp_core_block_css_files');
    /**
     * Fires after a site is fully upgraded.
     *
     * @since 3.9.0
     *
     * @param int $wp_db_version         The new $wp_db_version.
     * @param int $wp_current_db_version The old (current) $wp_db_version.
     */
    do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
}

WordPress Version: 5.3

/**
 * Runs WordPress Upgrade functions.
 *
 * Upgrades the database if needed during a site update.
 *
 * @since 2.1.0
 *
 * @global int  $wp_current_db_version The old (current) database version.
 * @global int  $wp_db_version         The new database version.
 * @global wpdb $wpdb                  WordPress database abstraction object.
 */
function wp_upgrade()
{
    global $wp_current_db_version, $wp_db_version, $wpdb;
    $wp_current_db_version = __get_option('db_version');
    // We are up to date. Nothing to do.
    if ($wp_db_version == $wp_current_db_version) {
        return;
    }
    if (!is_blog_installed()) {
        return;
    }
    wp_check_mysql_version();
    wp_cache_flush();
    pre_schema_upgrade();
    make_db_current_silent();
    upgrade_all();
    if (is_multisite() && is_main_site()) {
        upgrade_network();
    }
    wp_cache_flush();
    if (is_multisite()) {
        update_site_meta(get_current_blog_id(), 'db_version', $wp_db_version);
        update_site_meta(get_current_blog_id(), 'db_last_updated', microtime());
    }
    /**
     * Fires after a site is fully upgraded.
     *
     * @since 3.9.0
     *
     * @param int $wp_db_version         The new $wp_db_version.
     * @param int $wp_current_db_version The old (current) $wp_db_version.
     */
    do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
}

WordPress Version: 9.1

/**
 * Runs WordPress Upgrade functions.
 *
 * Upgrades the database if needed during a site update.
 *
 * @since 2.1.0
 *
 * @global int  $wp_current_db_version
 * @global int  $wp_db_version
 * @global wpdb $wpdb WordPress database abstraction object.
 */
function wp_upgrade()
{
    global $wp_current_db_version, $wp_db_version, $wpdb;
    $wp_current_db_version = __get_option('db_version');
    // We are up-to-date. Nothing to do.
    if ($wp_db_version == $wp_current_db_version) {
        return;
    }
    if (!is_blog_installed()) {
        return;
    }
    wp_check_mysql_version();
    wp_cache_flush();
    pre_schema_upgrade();
    make_db_current_silent();
    upgrade_all();
    if (is_multisite() && is_main_site()) {
        upgrade_network();
    }
    wp_cache_flush();
    if (is_multisite()) {
        $site_id = get_current_blog_id();
        if ($wpdb->get_row($wpdb->prepare("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = %d", $site_id))) {
            $wpdb->query($wpdb->prepare("UPDATE {$wpdb->blog_versions} SET db_version = %d WHERE blog_id = %d", $wp_db_version, $site_id));
        } else {
            $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( %d, %d, NOW() );", $site_id, $wp_db_version));
        }
    }
    /**
     * Fires after a site is fully upgraded.
     *
     * @since 3.9.0
     *
     * @param int $wp_db_version         The new $wp_db_version.
     * @param int $wp_current_db_version The old (current) $wp_db_version.
     */
    do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
}

WordPress Version: 4.9

/**
 * Runs WordPress Upgrade functions.
 *
 * Upgrades the database if needed during a site update.
 *
 * @since 2.1.0
 *
 * @global int  $wp_current_db_version
 * @global int  $wp_db_version
 * @global wpdb $wpdb WordPress database abstraction object.
 */
function wp_upgrade()
{
    global $wp_current_db_version, $wp_db_version, $wpdb;
    $wp_current_db_version = __get_option('db_version');
    // We are up-to-date. Nothing to do.
    if ($wp_db_version == $wp_current_db_version) {
        return;
    }
    if (!is_blog_installed()) {
        return;
    }
    wp_check_mysql_version();
    wp_cache_flush();
    pre_schema_upgrade();
    make_db_current_silent();
    upgrade_all();
    if (is_multisite() && is_main_site()) {
        upgrade_network();
    }
    wp_cache_flush();
    if (is_multisite()) {
        $site_id = get_current_blog_id();
        if ($wpdb->get_row($wpdb->prepare('SELECT blog_id FROM %s WHERE blog_id = %d', $wpdb->blog_versions, $site_id))) {
            $wpdb->query($wpdb->prepare('UPDATE %s SET db_version = %d WHERE blog_id = %d', $wpdb->blog_versions, $wp_db_version, $site_id));
        } else {
            $wpdb->query($wpdb->prepare('INSERT INTO %s ( `blog_id` , `db_version` , `last_updated` ) VALUES ( %d, %d, %s);', $wpdb->blog_versions, $site_id, $wp_db_version, NOW()));
        }
    }
    /**
     * Fires after a site is fully upgraded.
     *
     * @since 3.9.0
     *
     * @param int $wp_db_version         The new $wp_db_version.
     * @param int $wp_current_db_version The old (current) $wp_db_version.
     */
    do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
}

WordPress Version: 4.4

/**
 * Runs WordPress Upgrade functions.
 *
 * Upgrades the database if needed during a site update.
 *
 * @since 2.1.0
 *
 * @global int  $wp_current_db_version
 * @global int  $wp_db_version
 * @global wpdb $wpdb WordPress database abstraction object.
 */
function wp_upgrade()
{
    global $wp_current_db_version, $wp_db_version, $wpdb;
    $wp_current_db_version = __get_option('db_version');
    // We are up-to-date. Nothing to do.
    if ($wp_db_version == $wp_current_db_version) {
        return;
    }
    if (!is_blog_installed()) {
        return;
    }
    wp_check_mysql_version();
    wp_cache_flush();
    pre_schema_upgrade();
    make_db_current_silent();
    upgrade_all();
    if (is_multisite() && is_main_site()) {
        upgrade_network();
    }
    wp_cache_flush();
    if (is_multisite()) {
        if ($wpdb->get_row("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'")) {
            $wpdb->query("UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'");
        } else {
            $wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());");
        }
    }
    /**
     * Fires after a site is fully upgraded.
     *
     * @since 3.9.0
     *
     * @param int $wp_db_version         The new $wp_db_version.
     * @param int $wp_current_db_version The old (current) $wp_db_version.
     */
    do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
}

WordPress Version: 4.3

/**
 * Runs WordPress Upgrade functions.
 *
 * Upgrades the database if needed during a site update.
 *
 * @since 2.1.0
 *
 * @global int  $wp_current_db_version
 * @global int  $wp_db_version
 * @global wpdb $wpdb
 */
function wp_upgrade()
{
    global $wp_current_db_version, $wp_db_version, $wpdb;
    $wp_current_db_version = __get_option('db_version');
    // We are up-to-date. Nothing to do.
    if ($wp_db_version == $wp_current_db_version) {
        return;
    }
    if (!is_blog_installed()) {
        return;
    }
    wp_check_mysql_version();
    wp_cache_flush();
    pre_schema_upgrade();
    make_db_current_silent();
    upgrade_all();
    if (is_multisite() && is_main_site()) {
        upgrade_network();
    }
    wp_cache_flush();
    if (is_multisite()) {
        if ($wpdb->get_row("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'")) {
            $wpdb->query("UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'");
        } else {
            $wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());");
        }
    }
    /**
     * Fires after a site is fully upgraded.
     *
     * @since 3.9.0
     *
     * @param int $wp_db_version         The new $wp_db_version.
     * @param int $wp_current_db_version The old (current) $wp_db_version.
     */
    do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
}

WordPress Version: 4.2

/**
 * Runs WordPress Upgrade functions.
 *
 * Upgrades the database if needed during a site update.
 *
 * @since 2.1.0
 *
 * @return null If no update is necessary or site isn't completely installed, null.
 */
function wp_upgrade()
{
    global $wp_current_db_version, $wp_db_version, $wpdb;
    $wp_current_db_version = __get_option('db_version');
    // We are up-to-date. Nothing to do.
    if ($wp_db_version == $wp_current_db_version) {
        return;
    }
    if (!is_blog_installed()) {
        return;
    }
    wp_check_mysql_version();
    wp_cache_flush();
    pre_schema_upgrade();
    make_db_current_silent();
    upgrade_all();
    if (is_multisite() && is_main_site()) {
        upgrade_network();
    }
    wp_cache_flush();
    if (is_multisite()) {
        if ($wpdb->get_row("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'")) {
            $wpdb->query("UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'");
        } else {
            $wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());");
        }
    }
    /**
     * Fires after a site is fully upgraded.
     *
     * @since 3.9.0
     *
     * @param int $wp_db_version         The new $wp_db_version.
     * @param int $wp_current_db_version The old (current) $wp_db_version.
     */
    do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
}

WordPress Version: 3.9

/**
 * Run WordPress Upgrade functions.
 *
 * {@internal Missing Long Description}}
 *
 * @since 2.1.0
 *
 * @return null
 */
function wp_upgrade()
{
    global $wp_current_db_version, $wp_db_version, $wpdb;
    $wp_current_db_version = __get_option('db_version');
    // We are up-to-date. Nothing to do.
    if ($wp_db_version == $wp_current_db_version) {
        return;
    }
    if (!is_blog_installed()) {
        return;
    }
    wp_check_mysql_version();
    wp_cache_flush();
    pre_schema_upgrade();
    make_db_current_silent();
    upgrade_all();
    if (is_multisite() && is_main_site()) {
        upgrade_network();
    }
    wp_cache_flush();
    if (is_multisite()) {
        if ($wpdb->get_row("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'")) {
            $wpdb->query("UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'");
        } else {
            $wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());");
        }
    }
    /**
     * Fires after a site is fully upgraded.
     *
     * @since 3.9.0
     *
     * @param int $wp_db_version         The new $wp_db_version.
     * @param int $wp_current_db_version The old (current) $wp_db_version.
     */
    do_action('wp_upgrade', $wp_db_version, $wp_current_db_version);
}

WordPress Version: 3.7

/**
 * Run WordPress Upgrade functions.
 *
 * {@internal Missing Long Description}}
 *
 * @since 2.1.0
 *
 * @return null
 */
function wp_upgrade()
{
    global $wp_current_db_version, $wp_db_version, $wpdb;
    $wp_current_db_version = __get_option('db_version');
    // We are up-to-date. Nothing to do.
    if ($wp_db_version == $wp_current_db_version) {
        return;
    }
    if (!is_blog_installed()) {
        return;
    }
    wp_check_mysql_version();
    wp_cache_flush();
    pre_schema_upgrade();
    make_db_current_silent();
    upgrade_all();
    if (is_multisite() && is_main_site()) {
        upgrade_network();
    }
    wp_cache_flush();
    if (is_multisite()) {
        if ($wpdb->get_row("SELECT blog_id FROM {$wpdb->blog_versions} WHERE blog_id = '{$wpdb->blogid}'")) {
            $wpdb->query("UPDATE {$wpdb->blog_versions} SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'");
        } else {
            $wpdb->query("INSERT INTO {$wpdb->blog_versions} ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());");
        }
    }
}