: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Executes comments changes made in WordPress 4.3.0.
* @global wpdb $wpdb WordPress database abstraction object.
function upgrade_430_fix_comments() {
$content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
if ( is_wp_error( $content_length ) ) {
if ( false === $content_length ) {
} elseif ( ! is_array( $content_length ) ) {
$length = (int) $content_length > 0 ? (int) $content_length : 65535;
if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
// Sites with malformed DB schemas are on their own.
$allowed_length = (int) $content_length['length'] - 10;
$comments = $wpdb->get_results(
"SELECT `comment_ID` FROM `{$wpdb->comments}`
WHERE `comment_date_gmt` > '2015-04-26'
AND LENGTH( `comment_content` ) >= {$allowed_length}
AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
foreach ( $comments as $comment ) {
wp_delete_comment( $comment->comment_ID, true );
* Executes changes made in WordPress 4.3.1.
// Fix incorrect cron entries for term splitting.
$cron_array = _get_cron_array();
if ( isset( $cron_array['wp_batch_split_terms'] ) ) {
unset( $cron_array['wp_batch_split_terms'] );
_set_cron_array( $cron_array );
* Executes changes made in WordPress 4.4.0.
* @global int $wp_current_db_version The old (current) database version.
* @global wpdb $wpdb WordPress database abstraction object.
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 34030 ) {
$wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" );
// Remove the unused 'add_users' role.
foreach ( $roles->role_objects as $role ) {
if ( $role->has_cap( 'add_users' ) ) {
$role->remove_cap( 'add_users' );
* Executes changes made in WordPress 4.5.0.
* @global int $wp_current_db_version The old (current) database version.
* @global wpdb $wpdb WordPress database abstraction object.
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 36180 ) {
wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
// Remove unused email confirmation options, moved to usermeta.
if ( $wp_current_db_version < 36679 && is_multisite() ) {
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'" );
// Remove unused user setting for wpLink.
delete_user_setting( 'wplink' );
* Executes changes made in WordPress 4.6.0.
* @global int $wp_current_db_version The old (current) database version.
global $wp_current_db_version;
// Remove unused post meta.
if ( $wp_current_db_version < 37854 ) {
delete_post_meta_by_key( '_post_restored_from' );
// Remove plugins with callback as an array object/method as the uninstall hook, see #13786.
if ( $wp_current_db_version < 37965 ) {
$uninstall_plugins = get_option( 'uninstall_plugins', array() );
if ( ! empty( $uninstall_plugins ) ) {
foreach ( $uninstall_plugins as $basename => $callback ) {
if ( is_array( $callback ) && is_object( $callback[0] ) ) {
unset( $uninstall_plugins[ $basename ] );
update_option( 'uninstall_plugins', $uninstall_plugins );
* Executes changes made in WordPress 5.0.0.
* Executes changes made in WordPress 5.1.0.
delete_site_option( 'upgrade_500_was_gutenberg_active' );
* Executes changes made in WordPress 5.3.0.
* The `admin_email_lifespan` option may have been set by an admin that just logged in,
* saw the verification screen, clicked on a button there, and is now upgrading the db,
* or by populate_options() that is called earlier in upgrade_all().
* In the second case `admin_email_lifespan` should be reset so the verification screen
* is shown next time an admin logs in.
if ( function_exists( 'current_user_can' ) && ! current_user_can( 'manage_options' ) ) {
update_option( 'admin_email_lifespan', 0 );
* Executes changes made in WordPress 5.5.0.
* @global int $wp_current_db_version The old (current) database version.
global $wp_current_db_version;
if ( $wp_current_db_version < 48121 ) {
$comment_previously_approved = get_option( 'comment_whitelist', '' );
update_option( 'comment_previously_approved', $comment_previously_approved );
delete_option( 'comment_whitelist' );
if ( $wp_current_db_version < 48575 ) {
// Use more clear and inclusive language.
$disallowed_list = get_option( 'blacklist_keys' );
* This option key was briefly renamed `blocklist_keys`.
* Account for sites that have this key present when the original key does not exist.
if ( false === $disallowed_list ) {
$disallowed_list = get_option( 'blocklist_keys' );
update_option( 'disallowed_keys', $disallowed_list );
delete_option( 'blacklist_keys' );
delete_option( 'blocklist_keys' );
if ( $wp_current_db_version < 48748 ) {
update_option( 'finished_updating_comment_type', 0 );
wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
* Executes changes made in WordPress 5.6.0.
* @global int $wp_current_db_version The old (current) database version.
* @global wpdb $wpdb WordPress database abstraction object.
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(
"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 );
* Executes changes made in WordPress 5.9.0.
* @global int $wp_current_db_version The old (current) database version.
global $wp_current_db_version;
if ( $wp_current_db_version < 51917 ) {
$crons = _get_cron_array();
if ( $crons && is_array( $crons ) ) {
// Remove errant `false` values, see #53950, #54906.
$crons = array_filter( $crons );
_set_cron_array( $crons );
* Executes changes made in WordPress 6.0.0.
* @global int $wp_current_db_version The old (current) database version.
global $wp_current_db_version;
if ( $wp_current_db_version < 53011 ) {
* Executes changes made in WordPress 6.3.0.
* @global int $wp_current_db_version The old (current) database version.
global $wp_current_db_version;
if ( $wp_current_db_version < 55853 ) {
if ( ! is_multisite() ) {
// Replace non-autoload option can_compress_scripts with autoload option, see #55270
$can_compress_scripts = get_option( 'can_compress_scripts', false );
if ( false !== $can_compress_scripts ) {
delete_option( 'can_compress_scripts' );
add_option( 'can_compress_scripts', $can_compress_scripts, '', 'yes' );
* Executes changes made in WordPress 6.4.0.
* @global int $wp_current_db_version The old (current) database version.
global $wp_current_db_version;
if ( $wp_current_db_version < 56657 ) {
// Enable attachment pages.
update_option( 'wp_attachment_pages_enabled', 1 );
// Remove the wp_https_detection cron. Https status is checked directly in an async Site Health check.
$scheduled = wp_get_scheduled_event( 'wp_https_detection' );
wp_clear_scheduled_hook( 'wp_https_detection' );
* Executes changes made in WordPress 6.5.0.
* @global int $wp_current_db_version The old (current) database version.
* @global wpdb $wpdb WordPress database abstraction object.
global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 57155 ) {
$stylesheet = get_stylesheet();
// Set autoload=no for all themes except the current one.
$theme_mods_options = $wpdb->get_col(
"SELECT option_name FROM $wpdb->options WHERE autoload = 'yes' AND option_name != %s AND option_name LIKE %s",
"theme_mods_$stylesheet",
$wpdb->esc_like( 'theme_mods_' ) . '%'
$autoload = array_fill_keys( $theme_mods_options, 'no' );
wp_set_option_autoload_values( $autoload );
* Executes network-level upgrade routines.
* @global int $wp_current_db_version The old (current) database version.
* @global wpdb $wpdb WordPress database abstraction object.
function upgrade_network() {
global $wp_current_db_version, $wpdb;
// Always clear expired transients.
delete_expired_transients( true );
if ( $wp_current_db_version < 11549 ) {
$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
if ( $wpmu_sitewide_plugins ) {
if ( ! $active_sitewide_plugins ) {
$sitewide_plugins = (array) $wpmu_sitewide_plugins;
$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
delete_site_option( 'wpmu_sitewide_plugins' );
delete_site_option( 'deactivated_sitewide_plugins' );
while ( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
foreach ( $rows as $row ) {
$value = $row->meta_value;
if ( ! @unserialize( $value ) ) {
$value = stripslashes( $value );
if ( $value !== $row->meta_value ) {
update_site_option( $row->meta_key, $value );
if ( $wp_current_db_version < 13576 ) {
update_site_option( 'global_terms_enabled', '1' );
if ( $wp_current_db_version < 19390 ) {
update_site_option( 'initial_db_version', $wp_current_db_version );
if ( $wp_current_db_version < 19470 ) {
if ( false === get_site_option( 'active_sitewide_plugins' ) ) {
update_site_option( 'active_sitewide_plugins', array() );
if ( $wp_current_db_version < 20148 ) {
// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
$allowedthemes = get_site_option( 'allowedthemes' );
$allowed_themes = get_site_option( 'allowed_themes' );
if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
$themes = wp_get_themes();
foreach ( $themes as $stylesheet => $theme_data ) {
if ( isset( $allowed_themes[ $theme_data->get( 'Name' ) ] ) ) {
$converted[ $stylesheet ] = true;
update_site_option( 'allowedthemes', $converted );
delete_site_option( 'allowed_themes' );
if ( $wp_current_db_version < 21823 ) {
update_site_option( 'ms_files_rewriting', '1' );
if ( $wp_current_db_version < 24448 ) {
$illegal_names = get_site_option( 'illegal_names' );
if ( is_array( $illegal_names ) && count( $illegal_names ) === 1 ) {
$illegal_name = reset( $illegal_names );
$illegal_names = explode( ' ', $illegal_name );
update_site_option( 'illegal_names', $illegal_names );
if ( $wp_current_db_version < 31351 && 'utf8mb4' === $wpdb->charset ) {
if ( wp_should_upgrade_global_tables() ) {
$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
$wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
$wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );