Edit File by line
/home/barbar84/www/wp-admin/includes
File: upgrade.php
}
[2000] Fix | Delete
[2001] Fix | Delete
if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
[2002] Fix | Delete
if ( is_multisite() ) {
[2003] Fix | Delete
$tables = $wpdb->tables( 'blog' );
[2004] Fix | Delete
} else {
[2005] Fix | Delete
$tables = $wpdb->tables( 'all' );
[2006] Fix | Delete
if ( ! wp_should_upgrade_global_tables() ) {
[2007] Fix | Delete
$global_tables = $wpdb->tables( 'global' );
[2008] Fix | Delete
$tables = array_diff_assoc( $tables, $global_tables );
[2009] Fix | Delete
}
[2010] Fix | Delete
}
[2011] Fix | Delete
[2012] Fix | Delete
foreach ( $tables as $table ) {
[2013] Fix | Delete
maybe_convert_table_to_utf8mb4( $table );
[2014] Fix | Delete
}
[2015] Fix | Delete
}
[2016] Fix | Delete
}
[2017] Fix | Delete
[2018] Fix | Delete
/**
[2019] Fix | Delete
* Executes comments changes made in WordPress 4.3.0.
[2020] Fix | Delete
*
[2021] Fix | Delete
* @ignore
[2022] Fix | Delete
* @since 4.3.0
[2023] Fix | Delete
*
[2024] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2025] Fix | Delete
*/
[2026] Fix | Delete
function upgrade_430_fix_comments() {
[2027] Fix | Delete
global $wpdb;
[2028] Fix | Delete
[2029] Fix | Delete
$content_length = $wpdb->get_col_length( $wpdb->comments, 'comment_content' );
[2030] Fix | Delete
[2031] Fix | Delete
if ( is_wp_error( $content_length ) ) {
[2032] Fix | Delete
return;
[2033] Fix | Delete
}
[2034] Fix | Delete
[2035] Fix | Delete
if ( false === $content_length ) {
[2036] Fix | Delete
$content_length = array(
[2037] Fix | Delete
'type' => 'byte',
[2038] Fix | Delete
'length' => 65535,
[2039] Fix | Delete
);
[2040] Fix | Delete
} elseif ( ! is_array( $content_length ) ) {
[2041] Fix | Delete
$length = (int) $content_length > 0 ? (int) $content_length : 65535;
[2042] Fix | Delete
$content_length = array(
[2043] Fix | Delete
'type' => 'byte',
[2044] Fix | Delete
'length' => $length,
[2045] Fix | Delete
);
[2046] Fix | Delete
}
[2047] Fix | Delete
[2048] Fix | Delete
if ( 'byte' !== $content_length['type'] || 0 === $content_length['length'] ) {
[2049] Fix | Delete
// Sites with malformed DB schemas are on their own.
[2050] Fix | Delete
return;
[2051] Fix | Delete
}
[2052] Fix | Delete
[2053] Fix | Delete
$allowed_length = (int) $content_length['length'] - 10;
[2054] Fix | Delete
[2055] Fix | Delete
$comments = $wpdb->get_results(
[2056] Fix | Delete
"SELECT `comment_ID` FROM `{$wpdb->comments}`
[2057] Fix | Delete
WHERE `comment_date_gmt` > '2015-04-26'
[2058] Fix | Delete
AND LENGTH( `comment_content` ) >= {$allowed_length}
[2059] Fix | Delete
AND ( `comment_content` LIKE '%<%' OR `comment_content` LIKE '%>%' )"
[2060] Fix | Delete
);
[2061] Fix | Delete
[2062] Fix | Delete
foreach ( $comments as $comment ) {
[2063] Fix | Delete
wp_delete_comment( $comment->comment_ID, true );
[2064] Fix | Delete
}
[2065] Fix | Delete
}
[2066] Fix | Delete
[2067] Fix | Delete
/**
[2068] Fix | Delete
* Executes changes made in WordPress 4.3.1.
[2069] Fix | Delete
*
[2070] Fix | Delete
* @ignore
[2071] Fix | Delete
* @since 4.3.1
[2072] Fix | Delete
*/
[2073] Fix | Delete
function upgrade_431() {
[2074] Fix | Delete
// Fix incorrect cron entries for term splitting.
[2075] Fix | Delete
$cron_array = _get_cron_array();
[2076] Fix | Delete
if ( isset( $cron_array['wp_batch_split_terms'] ) ) {
[2077] Fix | Delete
unset( $cron_array['wp_batch_split_terms'] );
[2078] Fix | Delete
_set_cron_array( $cron_array );
[2079] Fix | Delete
}
[2080] Fix | Delete
}
[2081] Fix | Delete
[2082] Fix | Delete
/**
[2083] Fix | Delete
* Executes changes made in WordPress 4.4.0.
[2084] Fix | Delete
*
[2085] Fix | Delete
* @ignore
[2086] Fix | Delete
* @since 4.4.0
[2087] Fix | Delete
*
[2088] Fix | Delete
* @global int $wp_current_db_version The old (current) database version.
[2089] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2090] Fix | Delete
*/
[2091] Fix | Delete
function upgrade_440() {
[2092] Fix | Delete
global $wp_current_db_version, $wpdb;
[2093] Fix | Delete
[2094] Fix | Delete
if ( $wp_current_db_version < 34030 ) {
[2095] Fix | Delete
$wpdb->query( "ALTER TABLE {$wpdb->options} MODIFY option_name VARCHAR(191)" );
[2096] Fix | Delete
}
[2097] Fix | Delete
[2098] Fix | Delete
// Remove the unused 'add_users' role.
[2099] Fix | Delete
$roles = wp_roles();
[2100] Fix | Delete
foreach ( $roles->role_objects as $role ) {
[2101] Fix | Delete
if ( $role->has_cap( 'add_users' ) ) {
[2102] Fix | Delete
$role->remove_cap( 'add_users' );
[2103] Fix | Delete
}
[2104] Fix | Delete
}
[2105] Fix | Delete
}
[2106] Fix | Delete
[2107] Fix | Delete
/**
[2108] Fix | Delete
* Executes changes made in WordPress 4.5.0.
[2109] Fix | Delete
*
[2110] Fix | Delete
* @ignore
[2111] Fix | Delete
* @since 4.5.0
[2112] Fix | Delete
*
[2113] Fix | Delete
* @global int $wp_current_db_version The old (current) database version.
[2114] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2115] Fix | Delete
*/
[2116] Fix | Delete
function upgrade_450() {
[2117] Fix | Delete
global $wp_current_db_version, $wpdb;
[2118] Fix | Delete
[2119] Fix | Delete
if ( $wp_current_db_version < 36180 ) {
[2120] Fix | Delete
wp_clear_scheduled_hook( 'wp_maybe_auto_update' );
[2121] Fix | Delete
}
[2122] Fix | Delete
[2123] Fix | Delete
// Remove unused email confirmation options, moved to usermeta.
[2124] Fix | Delete
if ( $wp_current_db_version < 36679 && is_multisite() ) {
[2125] Fix | Delete
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^[0-9]+_new_email$'" );
[2126] Fix | Delete
}
[2127] Fix | Delete
[2128] Fix | Delete
// Remove unused user setting for wpLink.
[2129] Fix | Delete
delete_user_setting( 'wplink' );
[2130] Fix | Delete
}
[2131] Fix | Delete
[2132] Fix | Delete
/**
[2133] Fix | Delete
* Executes changes made in WordPress 4.6.0.
[2134] Fix | Delete
*
[2135] Fix | Delete
* @ignore
[2136] Fix | Delete
* @since 4.6.0
[2137] Fix | Delete
*
[2138] Fix | Delete
* @global int $wp_current_db_version The old (current) database version.
[2139] Fix | Delete
*/
[2140] Fix | Delete
function upgrade_460() {
[2141] Fix | Delete
global $wp_current_db_version;
[2142] Fix | Delete
[2143] Fix | Delete
// Remove unused post meta.
[2144] Fix | Delete
if ( $wp_current_db_version < 37854 ) {
[2145] Fix | Delete
delete_post_meta_by_key( '_post_restored_from' );
[2146] Fix | Delete
}
[2147] Fix | Delete
[2148] Fix | Delete
// Remove plugins with callback as an array object/method as the uninstall hook, see #13786.
[2149] Fix | Delete
if ( $wp_current_db_version < 37965 ) {
[2150] Fix | Delete
$uninstall_plugins = get_option( 'uninstall_plugins', array() );
[2151] Fix | Delete
[2152] Fix | Delete
if ( ! empty( $uninstall_plugins ) ) {
[2153] Fix | Delete
foreach ( $uninstall_plugins as $basename => $callback ) {
[2154] Fix | Delete
if ( is_array( $callback ) && is_object( $callback[0] ) ) {
[2155] Fix | Delete
unset( $uninstall_plugins[ $basename ] );
[2156] Fix | Delete
}
[2157] Fix | Delete
}
[2158] Fix | Delete
[2159] Fix | Delete
update_option( 'uninstall_plugins', $uninstall_plugins );
[2160] Fix | Delete
}
[2161] Fix | Delete
}
[2162] Fix | Delete
}
[2163] Fix | Delete
[2164] Fix | Delete
/**
[2165] Fix | Delete
* Executes changes made in WordPress 5.0.0.
[2166] Fix | Delete
*
[2167] Fix | Delete
* @ignore
[2168] Fix | Delete
* @since 5.0.0
[2169] Fix | Delete
* @deprecated 5.1.0
[2170] Fix | Delete
*/
[2171] Fix | Delete
function upgrade_500() {
[2172] Fix | Delete
}
[2173] Fix | Delete
[2174] Fix | Delete
/**
[2175] Fix | Delete
* Executes changes made in WordPress 5.1.0.
[2176] Fix | Delete
*
[2177] Fix | Delete
* @ignore
[2178] Fix | Delete
* @since 5.1.0
[2179] Fix | Delete
*/
[2180] Fix | Delete
function upgrade_510() {
[2181] Fix | Delete
delete_site_option( 'upgrade_500_was_gutenberg_active' );
[2182] Fix | Delete
}
[2183] Fix | Delete
[2184] Fix | Delete
/**
[2185] Fix | Delete
* Executes changes made in WordPress 5.3.0.
[2186] Fix | Delete
*
[2187] Fix | Delete
* @ignore
[2188] Fix | Delete
* @since 5.3.0
[2189] Fix | Delete
*/
[2190] Fix | Delete
function upgrade_530() {
[2191] Fix | Delete
/*
[2192] Fix | Delete
* The `admin_email_lifespan` option may have been set by an admin that just logged in,
[2193] Fix | Delete
* saw the verification screen, clicked on a button there, and is now upgrading the db,
[2194] Fix | Delete
* or by populate_options() that is called earlier in upgrade_all().
[2195] Fix | Delete
* In the second case `admin_email_lifespan` should be reset so the verification screen
[2196] Fix | Delete
* is shown next time an admin logs in.
[2197] Fix | Delete
*/
[2198] Fix | Delete
if ( function_exists( 'current_user_can' ) && ! current_user_can( 'manage_options' ) ) {
[2199] Fix | Delete
update_option( 'admin_email_lifespan', 0 );
[2200] Fix | Delete
}
[2201] Fix | Delete
}
[2202] Fix | Delete
[2203] Fix | Delete
/**
[2204] Fix | Delete
* Executes changes made in WordPress 5.5.0.
[2205] Fix | Delete
*
[2206] Fix | Delete
* @ignore
[2207] Fix | Delete
* @since 5.5.0
[2208] Fix | Delete
*/
[2209] Fix | Delete
function upgrade_550() {
[2210] Fix | Delete
global $wp_current_db_version;
[2211] Fix | Delete
[2212] Fix | Delete
if ( $wp_current_db_version < 48121 ) {
[2213] Fix | Delete
$comment_previously_approved = get_option( 'comment_whitelist', '' );
[2214] Fix | Delete
update_option( 'comment_previously_approved', $comment_previously_approved );
[2215] Fix | Delete
delete_option( 'comment_whitelist' );
[2216] Fix | Delete
}
[2217] Fix | Delete
[2218] Fix | Delete
if ( $wp_current_db_version < 48575 ) {
[2219] Fix | Delete
// Use more clear and inclusive language.
[2220] Fix | Delete
$disallowed_list = get_option( 'blacklist_keys' );
[2221] Fix | Delete
[2222] Fix | Delete
/*
[2223] Fix | Delete
* This option key was briefly renamed `blocklist_keys`.
[2224] Fix | Delete
* Account for sites that have this key present when the original key does not exist.
[2225] Fix | Delete
*/
[2226] Fix | Delete
if ( false === $disallowed_list ) {
[2227] Fix | Delete
$disallowed_list = get_option( 'blocklist_keys' );
[2228] Fix | Delete
}
[2229] Fix | Delete
[2230] Fix | Delete
update_option( 'disallowed_keys', $disallowed_list );
[2231] Fix | Delete
delete_option( 'blacklist_keys' );
[2232] Fix | Delete
delete_option( 'blocklist_keys' );
[2233] Fix | Delete
}
[2234] Fix | Delete
[2235] Fix | Delete
if ( $wp_current_db_version < 48748 ) {
[2236] Fix | Delete
update_option( 'finished_updating_comment_type', 0 );
[2237] Fix | Delete
wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
[2238] Fix | Delete
}
[2239] Fix | Delete
}
[2240] Fix | Delete
[2241] Fix | Delete
/**
[2242] Fix | Delete
* Executes changes made in WordPress 5.6.0.
[2243] Fix | Delete
*
[2244] Fix | Delete
* @ignore
[2245] Fix | Delete
* @since 5.6.0
[2246] Fix | Delete
*/
[2247] Fix | Delete
function upgrade_560() {
[2248] Fix | Delete
global $wp_current_db_version, $wpdb;
[2249] Fix | Delete
[2250] Fix | Delete
if ( $wp_current_db_version < 49572 ) {
[2251] Fix | Delete
/*
[2252] Fix | Delete
* Clean up the `post_category` column removed from schema in version 2.8.0.
[2253] Fix | Delete
* Its presence may conflict with `WP_Post::__get()`.
[2254] Fix | Delete
*/
[2255] Fix | Delete
$post_category_exists = $wpdb->get_var( "SHOW COLUMNS FROM $wpdb->posts LIKE 'post_category'" );
[2256] Fix | Delete
if ( ! is_null( $post_category_exists ) ) {
[2257] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->posts DROP COLUMN `post_category`" );
[2258] Fix | Delete
}
[2259] Fix | Delete
[2260] Fix | Delete
/*
[2261] Fix | Delete
* When upgrading from WP < 5.6.0 set the core major auto-updates option to `unset` by default.
[2262] Fix | Delete
* This overrides the same option from populate_options() that is intended for new installs.
[2263] Fix | Delete
* See https://core.trac.wordpress.org/ticket/51742.
[2264] Fix | Delete
*/
[2265] Fix | Delete
update_option( 'auto_update_core_major', 'unset' );
[2266] Fix | Delete
}
[2267] Fix | Delete
[2268] Fix | Delete
if ( $wp_current_db_version < 49632 ) {
[2269] Fix | Delete
/*
[2270] Fix | Delete
* Regenerate the .htaccess file to add the `HTTP_AUTHORIZATION` rewrite rule.
[2271] Fix | Delete
* See https://core.trac.wordpress.org/ticket/51723.
[2272] Fix | Delete
*/
[2273] Fix | Delete
save_mod_rewrite_rules();
[2274] Fix | Delete
}
[2275] Fix | Delete
[2276] Fix | Delete
if ( $wp_current_db_version < 49735 ) {
[2277] Fix | Delete
delete_transient( 'dirsize_cache' );
[2278] Fix | Delete
}
[2279] Fix | Delete
[2280] Fix | Delete
if ( $wp_current_db_version < 49752 ) {
[2281] Fix | Delete
$results = $wpdb->get_results(
[2282] Fix | Delete
$wpdb->prepare(
[2283] Fix | Delete
"SELECT 1 FROM {$wpdb->usermeta} WHERE meta_key = %s LIMIT 1",
[2284] Fix | Delete
WP_Application_Passwords::USERMETA_KEY_APPLICATION_PASSWORDS
[2285] Fix | Delete
)
[2286] Fix | Delete
);
[2287] Fix | Delete
[2288] Fix | Delete
if ( ! empty( $results ) ) {
[2289] Fix | Delete
$network_id = get_main_network_id();
[2290] Fix | Delete
update_network_option( $network_id, WP_Application_Passwords::OPTION_KEY_IN_USE, 1 );
[2291] Fix | Delete
}
[2292] Fix | Delete
}
[2293] Fix | Delete
}
[2294] Fix | Delete
[2295] Fix | Delete
/**
[2296] Fix | Delete
* Executes network-level upgrade routines.
[2297] Fix | Delete
*
[2298] Fix | Delete
* @since 3.0.0
[2299] Fix | Delete
*
[2300] Fix | Delete
* @global int $wp_current_db_version The old (current) database version.
[2301] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2302] Fix | Delete
*/
[2303] Fix | Delete
function upgrade_network() {
[2304] Fix | Delete
global $wp_current_db_version, $wpdb;
[2305] Fix | Delete
[2306] Fix | Delete
// Always clear expired transients.
[2307] Fix | Delete
delete_expired_transients( true );
[2308] Fix | Delete
[2309] Fix | Delete
// 2.8.0
[2310] Fix | Delete
if ( $wp_current_db_version < 11549 ) {
[2311] Fix | Delete
$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
[2312] Fix | Delete
$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
[2313] Fix | Delete
if ( $wpmu_sitewide_plugins ) {
[2314] Fix | Delete
if ( ! $active_sitewide_plugins ) {
[2315] Fix | Delete
$sitewide_plugins = (array) $wpmu_sitewide_plugins;
[2316] Fix | Delete
} else {
[2317] Fix | Delete
$sitewide_plugins = array_merge( (array) $active_sitewide_plugins, (array) $wpmu_sitewide_plugins );
[2318] Fix | Delete
}
[2319] Fix | Delete
[2320] Fix | Delete
update_site_option( 'active_sitewide_plugins', $sitewide_plugins );
[2321] Fix | Delete
}
[2322] Fix | Delete
delete_site_option( 'wpmu_sitewide_plugins' );
[2323] Fix | Delete
delete_site_option( 'deactivated_sitewide_plugins' );
[2324] Fix | Delete
[2325] Fix | Delete
$start = 0;
[2326] Fix | Delete
while ( $rows = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->sitemeta} ORDER BY meta_id LIMIT $start, 20" ) ) {
[2327] Fix | Delete
foreach ( $rows as $row ) {
[2328] Fix | Delete
$value = $row->meta_value;
[2329] Fix | Delete
if ( ! @unserialize( $value ) ) {
[2330] Fix | Delete
$value = stripslashes( $value );
[2331] Fix | Delete
}
[2332] Fix | Delete
if ( $value !== $row->meta_value ) {
[2333] Fix | Delete
update_site_option( $row->meta_key, $value );
[2334] Fix | Delete
}
[2335] Fix | Delete
}
[2336] Fix | Delete
$start += 20;
[2337] Fix | Delete
}
[2338] Fix | Delete
}
[2339] Fix | Delete
[2340] Fix | Delete
// 3.0.0
[2341] Fix | Delete
if ( $wp_current_db_version < 13576 ) {
[2342] Fix | Delete
update_site_option( 'global_terms_enabled', '1' );
[2343] Fix | Delete
}
[2344] Fix | Delete
[2345] Fix | Delete
// 3.3.0
[2346] Fix | Delete
if ( $wp_current_db_version < 19390 ) {
[2347] Fix | Delete
update_site_option( 'initial_db_version', $wp_current_db_version );
[2348] Fix | Delete
}
[2349] Fix | Delete
[2350] Fix | Delete
if ( $wp_current_db_version < 19470 ) {
[2351] Fix | Delete
if ( false === get_site_option( 'active_sitewide_plugins' ) ) {
[2352] Fix | Delete
update_site_option( 'active_sitewide_plugins', array() );
[2353] Fix | Delete
}
[2354] Fix | Delete
}
[2355] Fix | Delete
[2356] Fix | Delete
// 3.4.0
[2357] Fix | Delete
if ( $wp_current_db_version < 20148 ) {
[2358] Fix | Delete
// 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name.
[2359] Fix | Delete
$allowedthemes = get_site_option( 'allowedthemes' );
[2360] Fix | Delete
$allowed_themes = get_site_option( 'allowed_themes' );
[2361] Fix | Delete
if ( false === $allowedthemes && is_array( $allowed_themes ) && $allowed_themes ) {
[2362] Fix | Delete
$converted = array();
[2363] Fix | Delete
$themes = wp_get_themes();
[2364] Fix | Delete
foreach ( $themes as $stylesheet => $theme_data ) {
[2365] Fix | Delete
if ( isset( $allowed_themes[ $theme_data->get( 'Name' ) ] ) ) {
[2366] Fix | Delete
$converted[ $stylesheet ] = true;
[2367] Fix | Delete
}
[2368] Fix | Delete
}
[2369] Fix | Delete
update_site_option( 'allowedthemes', $converted );
[2370] Fix | Delete
delete_site_option( 'allowed_themes' );
[2371] Fix | Delete
}
[2372] Fix | Delete
}
[2373] Fix | Delete
[2374] Fix | Delete
// 3.5.0
[2375] Fix | Delete
if ( $wp_current_db_version < 21823 ) {
[2376] Fix | Delete
update_site_option( 'ms_files_rewriting', '1' );
[2377] Fix | Delete
}
[2378] Fix | Delete
[2379] Fix | Delete
// 3.5.2
[2380] Fix | Delete
if ( $wp_current_db_version < 24448 ) {
[2381] Fix | Delete
$illegal_names = get_site_option( 'illegal_names' );
[2382] Fix | Delete
if ( is_array( $illegal_names ) && count( $illegal_names ) === 1 ) {
[2383] Fix | Delete
$illegal_name = reset( $illegal_names );
[2384] Fix | Delete
$illegal_names = explode( ' ', $illegal_name );
[2385] Fix | Delete
update_site_option( 'illegal_names', $illegal_names );
[2386] Fix | Delete
}
[2387] Fix | Delete
}
[2388] Fix | Delete
[2389] Fix | Delete
// 4.2.0
[2390] Fix | Delete
if ( $wp_current_db_version < 31351 && 'utf8mb4' === $wpdb->charset ) {
[2391] Fix | Delete
if ( wp_should_upgrade_global_tables() ) {
[2392] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
[2393] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->site DROP INDEX domain, ADD INDEX domain(domain(140),path(51))" );
[2394] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->sitemeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
[2395] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
[2396] Fix | Delete
[2397] Fix | Delete
$tables = $wpdb->tables( 'global' );
[2398] Fix | Delete
[2399] Fix | Delete
// sitecategories may not exist.
[2400] Fix | Delete
if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
[2401] Fix | Delete
unset( $tables['sitecategories'] );
[2402] Fix | Delete
}
[2403] Fix | Delete
[2404] Fix | Delete
foreach ( $tables as $table ) {
[2405] Fix | Delete
maybe_convert_table_to_utf8mb4( $table );
[2406] Fix | Delete
}
[2407] Fix | Delete
}
[2408] Fix | Delete
}
[2409] Fix | Delete
[2410] Fix | Delete
// 4.3.0
[2411] Fix | Delete
if ( $wp_current_db_version < 33055 && 'utf8mb4' === $wpdb->charset ) {
[2412] Fix | Delete
if ( wp_should_upgrade_global_tables() ) {
[2413] Fix | Delete
$upgrade = false;
[2414] Fix | Delete
$indexes = $wpdb->get_results( "SHOW INDEXES FROM $wpdb->signups" );
[2415] Fix | Delete
foreach ( $indexes as $index ) {
[2416] Fix | Delete
if ( 'domain_path' === $index->Key_name && 'domain' === $index->Column_name && 140 != $index->Sub_part ) {
[2417] Fix | Delete
$upgrade = true;
[2418] Fix | Delete
break;
[2419] Fix | Delete
}
[2420] Fix | Delete
}
[2421] Fix | Delete
[2422] Fix | Delete
if ( $upgrade ) {
[2423] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain_path, ADD INDEX domain_path(domain(140),path(51))" );
[2424] Fix | Delete
}
[2425] Fix | Delete
[2426] Fix | Delete
$tables = $wpdb->tables( 'global' );
[2427] Fix | Delete
[2428] Fix | Delete
// sitecategories may not exist.
[2429] Fix | Delete
if ( ! $wpdb->get_var( "SHOW TABLES LIKE '{$tables['sitecategories']}'" ) ) {
[2430] Fix | Delete
unset( $tables['sitecategories'] );
[2431] Fix | Delete
}
[2432] Fix | Delete
[2433] Fix | Delete
foreach ( $tables as $table ) {
[2434] Fix | Delete
maybe_convert_table_to_utf8mb4( $table );
[2435] Fix | Delete
}
[2436] Fix | Delete
}
[2437] Fix | Delete
}
[2438] Fix | Delete
[2439] Fix | Delete
// 5.1.0
[2440] Fix | Delete
if ( $wp_current_db_version < 44467 ) {
[2441] Fix | Delete
$network_id = get_main_network_id();
[2442] Fix | Delete
delete_network_option( $network_id, 'site_meta_supported' );
[2443] Fix | Delete
is_site_meta_supported();
[2444] Fix | Delete
}
[2445] Fix | Delete
}
[2446] Fix | Delete
[2447] Fix | Delete
//
[2448] Fix | Delete
// General functions we use to actually do stuff.
[2449] Fix | Delete
//
[2450] Fix | Delete
[2451] Fix | Delete
/**
[2452] Fix | Delete
* Creates a table in the database, if it doesn't already exist.
[2453] Fix | Delete
*
[2454] Fix | Delete
* This method checks for an existing database and creates a new one if it's not
[2455] Fix | Delete
* already present. It doesn't rely on MySQL's "IF NOT EXISTS" statement, but chooses
[2456] Fix | Delete
* to query all tables first and then run the SQL statement creating the table.
[2457] Fix | Delete
*
[2458] Fix | Delete
* @since 1.0.0
[2459] Fix | Delete
*
[2460] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2461] Fix | Delete
*
[2462] Fix | Delete
* @param string $table_name Database table name.
[2463] Fix | Delete
* @param string $create_ddl SQL statement to create table.
[2464] Fix | Delete
* @return bool True on success or if the table already exists. False on failure.
[2465] Fix | Delete
*/
[2466] Fix | Delete
function maybe_create_table( $table_name, $create_ddl ) {
[2467] Fix | Delete
global $wpdb;
[2468] Fix | Delete
[2469] Fix | Delete
$query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
[2470] Fix | Delete
[2471] Fix | Delete
if ( $wpdb->get_var( $query ) === $table_name ) {
[2472] Fix | Delete
return true;
[2473] Fix | Delete
}
[2474] Fix | Delete
[2475] Fix | Delete
// Didn't find it, so try to create it.
[2476] Fix | Delete
$wpdb->query( $create_ddl );
[2477] Fix | Delete
[2478] Fix | Delete
// We cannot directly tell that whether this succeeded!
[2479] Fix | Delete
if ( $wpdb->get_var( $query ) === $table_name ) {
[2480] Fix | Delete
return true;
[2481] Fix | Delete
}
[2482] Fix | Delete
[2483] Fix | Delete
return false;
[2484] Fix | Delete
}
[2485] Fix | Delete
[2486] Fix | Delete
/**
[2487] Fix | Delete
* Drops a specified index from a table.
[2488] Fix | Delete
*
[2489] Fix | Delete
* @since 1.0.1
[2490] Fix | Delete
*
[2491] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2492] Fix | Delete
*
[2493] Fix | Delete
* @param string $table Database table name.
[2494] Fix | Delete
* @param string $index Index name to drop.
[2495] Fix | Delete
* @return true True, when finished.
[2496] Fix | Delete
*/
[2497] Fix | Delete
function drop_index( $table, $index ) {
[2498] Fix | Delete
global $wpdb;
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function