Edit File by line
/home/barbar84/www/wp-admin/includes
File: upgrade.php
if ( $tableindices ) {
[3000] Fix | Delete
// Clear the index array.
[3001] Fix | Delete
$index_ary = array();
[3002] Fix | Delete
[3003] Fix | Delete
// For every index in the table.
[3004] Fix | Delete
foreach ( $tableindices as $tableindex ) {
[3005] Fix | Delete
$keyname = strtolower( $tableindex->Key_name );
[3006] Fix | Delete
[3007] Fix | Delete
// Add the index to the index data array.
[3008] Fix | Delete
$index_ary[ $keyname ]['columns'][] = array(
[3009] Fix | Delete
'fieldname' => $tableindex->Column_name,
[3010] Fix | Delete
'subpart' => $tableindex->Sub_part,
[3011] Fix | Delete
);
[3012] Fix | Delete
$index_ary[ $keyname ]['unique'] = ( 0 == $tableindex->Non_unique ) ? true : false;
[3013] Fix | Delete
$index_ary[ $keyname ]['index_type'] = $tableindex->Index_type;
[3014] Fix | Delete
}
[3015] Fix | Delete
[3016] Fix | Delete
// For each actual index in the index array.
[3017] Fix | Delete
foreach ( $index_ary as $index_name => $index_data ) {
[3018] Fix | Delete
[3019] Fix | Delete
// Build a create string to compare to the query.
[3020] Fix | Delete
$index_string = '';
[3021] Fix | Delete
if ( 'primary' === $index_name ) {
[3022] Fix | Delete
$index_string .= 'PRIMARY ';
[3023] Fix | Delete
} elseif ( $index_data['unique'] ) {
[3024] Fix | Delete
$index_string .= 'UNIQUE ';
[3025] Fix | Delete
}
[3026] Fix | Delete
if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) {
[3027] Fix | Delete
$index_string .= 'FULLTEXT ';
[3028] Fix | Delete
}
[3029] Fix | Delete
if ( 'SPATIAL' === strtoupper( $index_data['index_type'] ) ) {
[3030] Fix | Delete
$index_string .= 'SPATIAL ';
[3031] Fix | Delete
}
[3032] Fix | Delete
$index_string .= 'KEY ';
[3033] Fix | Delete
if ( 'primary' !== $index_name ) {
[3034] Fix | Delete
$index_string .= '`' . $index_name . '`';
[3035] Fix | Delete
}
[3036] Fix | Delete
$index_columns = '';
[3037] Fix | Delete
[3038] Fix | Delete
// For each column in the index.
[3039] Fix | Delete
foreach ( $index_data['columns'] as $column_data ) {
[3040] Fix | Delete
if ( '' !== $index_columns ) {
[3041] Fix | Delete
$index_columns .= ',';
[3042] Fix | Delete
}
[3043] Fix | Delete
[3044] Fix | Delete
// Add the field to the column list string.
[3045] Fix | Delete
$index_columns .= '`' . $column_data['fieldname'] . '`';
[3046] Fix | Delete
}
[3047] Fix | Delete
[3048] Fix | Delete
// Add the column list to the index create string.
[3049] Fix | Delete
$index_string .= " ($index_columns)";
[3050] Fix | Delete
[3051] Fix | Delete
// Check if the index definition exists, ignoring subparts.
[3052] Fix | Delete
$aindex = array_search( $index_string, $indices_without_subparts, true );
[3053] Fix | Delete
if ( false !== $aindex ) {
[3054] Fix | Delete
// If the index already exists (even with different subparts), we don't need to create it.
[3055] Fix | Delete
unset( $indices_without_subparts[ $aindex ] );
[3056] Fix | Delete
unset( $indices[ $aindex ] );
[3057] Fix | Delete
}
[3058] Fix | Delete
}
[3059] Fix | Delete
}
[3060] Fix | Delete
[3061] Fix | Delete
// For every remaining index specified for the table.
[3062] Fix | Delete
foreach ( (array) $indices as $index ) {
[3063] Fix | Delete
// Push a query line into $cqueries that adds the index to that table.
[3064] Fix | Delete
$cqueries[] = "ALTER TABLE {$table} ADD $index";
[3065] Fix | Delete
[3066] Fix | Delete
$for_update[] = 'Added index ' . $table . ' ' . $index;
[3067] Fix | Delete
}
[3068] Fix | Delete
[3069] Fix | Delete
// Remove the original table creation query from processing.
[3070] Fix | Delete
unset( $cqueries[ $table ], $for_update[ $table ] );
[3071] Fix | Delete
}
[3072] Fix | Delete
[3073] Fix | Delete
$allqueries = array_merge( $cqueries, $iqueries );
[3074] Fix | Delete
if ( $execute ) {
[3075] Fix | Delete
foreach ( $allqueries as $query ) {
[3076] Fix | Delete
$wpdb->query( $query );
[3077] Fix | Delete
}
[3078] Fix | Delete
}
[3079] Fix | Delete
[3080] Fix | Delete
return $for_update;
[3081] Fix | Delete
}
[3082] Fix | Delete
[3083] Fix | Delete
/**
[3084] Fix | Delete
* Updates the database tables to a new schema.
[3085] Fix | Delete
*
[3086] Fix | Delete
* By default, updates all the tables to use the latest defined schema, but can also
[3087] Fix | Delete
* be used to update a specific set of tables in wp_get_db_schema().
[3088] Fix | Delete
*
[3089] Fix | Delete
* @since 1.5.0
[3090] Fix | Delete
*
[3091] Fix | Delete
* @uses dbDelta
[3092] Fix | Delete
*
[3093] Fix | Delete
* @param string $tables Optional. Which set of tables to update. Default is 'all'.
[3094] Fix | Delete
*/
[3095] Fix | Delete
function make_db_current( $tables = 'all' ) {
[3096] Fix | Delete
$alterations = dbDelta( $tables );
[3097] Fix | Delete
echo "<ol>\n";
[3098] Fix | Delete
foreach ( $alterations as $alteration ) {
[3099] Fix | Delete
echo "<li>$alteration</li>\n";
[3100] Fix | Delete
}
[3101] Fix | Delete
echo "</ol>\n";
[3102] Fix | Delete
}
[3103] Fix | Delete
[3104] Fix | Delete
/**
[3105] Fix | Delete
* Updates the database tables to a new schema, but without displaying results.
[3106] Fix | Delete
*
[3107] Fix | Delete
* By default, updates all the tables to use the latest defined schema, but can
[3108] Fix | Delete
* also be used to update a specific set of tables in wp_get_db_schema().
[3109] Fix | Delete
*
[3110] Fix | Delete
* @since 1.5.0
[3111] Fix | Delete
*
[3112] Fix | Delete
* @see make_db_current()
[3113] Fix | Delete
*
[3114] Fix | Delete
* @param string $tables Optional. Which set of tables to update. Default is 'all'.
[3115] Fix | Delete
*/
[3116] Fix | Delete
function make_db_current_silent( $tables = 'all' ) {
[3117] Fix | Delete
dbDelta( $tables );
[3118] Fix | Delete
}
[3119] Fix | Delete
[3120] Fix | Delete
/**
[3121] Fix | Delete
* Creates a site theme from an existing theme.
[3122] Fix | Delete
*
[3123] Fix | Delete
* {@internal Missing Long Description}}
[3124] Fix | Delete
*
[3125] Fix | Delete
* @since 1.5.0
[3126] Fix | Delete
*
[3127] Fix | Delete
* @param string $theme_name The name of the theme.
[3128] Fix | Delete
* @param string $template The directory name of the theme.
[3129] Fix | Delete
* @return bool
[3130] Fix | Delete
*/
[3131] Fix | Delete
function make_site_theme_from_oldschool( $theme_name, $template ) {
[3132] Fix | Delete
$home_path = get_home_path();
[3133] Fix | Delete
$site_dir = WP_CONTENT_DIR . "/themes/$template";
[3134] Fix | Delete
[3135] Fix | Delete
if ( ! file_exists( "$home_path/index.php" ) ) {
[3136] Fix | Delete
return false;
[3137] Fix | Delete
}
[3138] Fix | Delete
[3139] Fix | Delete
/*
[3140] Fix | Delete
* Copy files from the old locations to the site theme.
[3141] Fix | Delete
* TODO: This does not copy arbitrary include dependencies. Only the standard WP files are copied.
[3142] Fix | Delete
*/
[3143] Fix | Delete
$files = array(
[3144] Fix | Delete
'index.php' => 'index.php',
[3145] Fix | Delete
'wp-layout.css' => 'style.css',
[3146] Fix | Delete
'wp-comments.php' => 'comments.php',
[3147] Fix | Delete
'wp-comments-popup.php' => 'comments-popup.php',
[3148] Fix | Delete
);
[3149] Fix | Delete
[3150] Fix | Delete
foreach ( $files as $oldfile => $newfile ) {
[3151] Fix | Delete
if ( 'index.php' === $oldfile ) {
[3152] Fix | Delete
$oldpath = $home_path;
[3153] Fix | Delete
} else {
[3154] Fix | Delete
$oldpath = ABSPATH;
[3155] Fix | Delete
}
[3156] Fix | Delete
[3157] Fix | Delete
// Check to make sure it's not a new index.
[3158] Fix | Delete
if ( 'index.php' === $oldfile ) {
[3159] Fix | Delete
$index = implode( '', file( "$oldpath/$oldfile" ) );
[3160] Fix | Delete
if ( strpos( $index, 'WP_USE_THEMES' ) !== false ) {
[3161] Fix | Delete
if ( ! copy( WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile" ) ) {
[3162] Fix | Delete
return false;
[3163] Fix | Delete
}
[3164] Fix | Delete
[3165] Fix | Delete
// Don't copy anything.
[3166] Fix | Delete
continue;
[3167] Fix | Delete
}
[3168] Fix | Delete
}
[3169] Fix | Delete
[3170] Fix | Delete
if ( ! copy( "$oldpath/$oldfile", "$site_dir/$newfile" ) ) {
[3171] Fix | Delete
return false;
[3172] Fix | Delete
}
[3173] Fix | Delete
[3174] Fix | Delete
chmod( "$site_dir/$newfile", 0777 );
[3175] Fix | Delete
[3176] Fix | Delete
// Update the blog header include in each file.
[3177] Fix | Delete
$lines = explode( "\n", implode( '', file( "$site_dir/$newfile" ) ) );
[3178] Fix | Delete
if ( $lines ) {
[3179] Fix | Delete
$f = fopen( "$site_dir/$newfile", 'w' );
[3180] Fix | Delete
[3181] Fix | Delete
foreach ( $lines as $line ) {
[3182] Fix | Delete
if ( preg_match( '/require.*wp-blog-header/', $line ) ) {
[3183] Fix | Delete
$line = '//' . $line;
[3184] Fix | Delete
}
[3185] Fix | Delete
[3186] Fix | Delete
// Update stylesheet references.
[3187] Fix | Delete
$line = str_replace( "<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line );
[3188] Fix | Delete
[3189] Fix | Delete
// Update comments template inclusion.
[3190] Fix | Delete
$line = str_replace( "<?php include(ABSPATH . 'wp-comments.php'); ?>", '<?php comments_template(); ?>', $line );
[3191] Fix | Delete
[3192] Fix | Delete
fwrite( $f, "{$line}\n" );
[3193] Fix | Delete
}
[3194] Fix | Delete
fclose( $f );
[3195] Fix | Delete
}
[3196] Fix | Delete
}
[3197] Fix | Delete
[3198] Fix | Delete
// Add a theme header.
[3199] Fix | Delete
$header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option( 'siteurl' ) . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n";
[3200] Fix | Delete
[3201] Fix | Delete
$stylelines = file_get_contents( "$site_dir/style.css" );
[3202] Fix | Delete
if ( $stylelines ) {
[3203] Fix | Delete
$f = fopen( "$site_dir/style.css", 'w' );
[3204] Fix | Delete
[3205] Fix | Delete
fwrite( $f, $header );
[3206] Fix | Delete
fwrite( $f, $stylelines );
[3207] Fix | Delete
fclose( $f );
[3208] Fix | Delete
}
[3209] Fix | Delete
[3210] Fix | Delete
return true;
[3211] Fix | Delete
}
[3212] Fix | Delete
[3213] Fix | Delete
/**
[3214] Fix | Delete
* Creates a site theme from the default theme.
[3215] Fix | Delete
*
[3216] Fix | Delete
* {@internal Missing Long Description}}
[3217] Fix | Delete
*
[3218] Fix | Delete
* @since 1.5.0
[3219] Fix | Delete
*
[3220] Fix | Delete
* @param string $theme_name The name of the theme.
[3221] Fix | Delete
* @param string $template The directory name of the theme.
[3222] Fix | Delete
* @return void|false
[3223] Fix | Delete
*/
[3224] Fix | Delete
function make_site_theme_from_default( $theme_name, $template ) {
[3225] Fix | Delete
$site_dir = WP_CONTENT_DIR . "/themes/$template";
[3226] Fix | Delete
$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
[3227] Fix | Delete
[3228] Fix | Delete
// Copy files from the default theme to the site theme.
[3229] Fix | Delete
// $files = array( 'index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css' );
[3230] Fix | Delete
[3231] Fix | Delete
$theme_dir = @opendir( $default_dir );
[3232] Fix | Delete
if ( $theme_dir ) {
[3233] Fix | Delete
while ( ( $theme_file = readdir( $theme_dir ) ) !== false ) {
[3234] Fix | Delete
if ( is_dir( "$default_dir/$theme_file" ) ) {
[3235] Fix | Delete
continue;
[3236] Fix | Delete
}
[3237] Fix | Delete
if ( ! copy( "$default_dir/$theme_file", "$site_dir/$theme_file" ) ) {
[3238] Fix | Delete
return;
[3239] Fix | Delete
}
[3240] Fix | Delete
chmod( "$site_dir/$theme_file", 0777 );
[3241] Fix | Delete
}
[3242] Fix | Delete
[3243] Fix | Delete
closedir( $theme_dir );
[3244] Fix | Delete
}
[3245] Fix | Delete
[3246] Fix | Delete
// Rewrite the theme header.
[3247] Fix | Delete
$stylelines = explode( "\n", implode( '', file( "$site_dir/style.css" ) ) );
[3248] Fix | Delete
if ( $stylelines ) {
[3249] Fix | Delete
$f = fopen( "$site_dir/style.css", 'w' );
[3250] Fix | Delete
[3251] Fix | Delete
foreach ( $stylelines as $line ) {
[3252] Fix | Delete
if ( strpos( $line, 'Theme Name:' ) !== false ) {
[3253] Fix | Delete
$line = 'Theme Name: ' . $theme_name;
[3254] Fix | Delete
} elseif ( strpos( $line, 'Theme URI:' ) !== false ) {
[3255] Fix | Delete
$line = 'Theme URI: ' . __get_option( 'url' );
[3256] Fix | Delete
} elseif ( strpos( $line, 'Description:' ) !== false ) {
[3257] Fix | Delete
$line = 'Description: Your theme.';
[3258] Fix | Delete
} elseif ( strpos( $line, 'Version:' ) !== false ) {
[3259] Fix | Delete
$line = 'Version: 1';
[3260] Fix | Delete
} elseif ( strpos( $line, 'Author:' ) !== false ) {
[3261] Fix | Delete
$line = 'Author: You';
[3262] Fix | Delete
}
[3263] Fix | Delete
fwrite( $f, $line . "\n" );
[3264] Fix | Delete
}
[3265] Fix | Delete
fclose( $f );
[3266] Fix | Delete
}
[3267] Fix | Delete
[3268] Fix | Delete
// Copy the images.
[3269] Fix | Delete
umask( 0 );
[3270] Fix | Delete
if ( ! mkdir( "$site_dir/images", 0777 ) ) {
[3271] Fix | Delete
return false;
[3272] Fix | Delete
}
[3273] Fix | Delete
[3274] Fix | Delete
$images_dir = @opendir( "$default_dir/images" );
[3275] Fix | Delete
if ( $images_dir ) {
[3276] Fix | Delete
while ( ( $image = readdir( $images_dir ) ) !== false ) {
[3277] Fix | Delete
if ( is_dir( "$default_dir/images/$image" ) ) {
[3278] Fix | Delete
continue;
[3279] Fix | Delete
}
[3280] Fix | Delete
if ( ! copy( "$default_dir/images/$image", "$site_dir/images/$image" ) ) {
[3281] Fix | Delete
return;
[3282] Fix | Delete
}
[3283] Fix | Delete
chmod( "$site_dir/images/$image", 0777 );
[3284] Fix | Delete
}
[3285] Fix | Delete
[3286] Fix | Delete
closedir( $images_dir );
[3287] Fix | Delete
}
[3288] Fix | Delete
}
[3289] Fix | Delete
[3290] Fix | Delete
/**
[3291] Fix | Delete
* Creates a site theme.
[3292] Fix | Delete
*
[3293] Fix | Delete
* {@internal Missing Long Description}}
[3294] Fix | Delete
*
[3295] Fix | Delete
* @since 1.5.0
[3296] Fix | Delete
*
[3297] Fix | Delete
* @return string|false
[3298] Fix | Delete
*/
[3299] Fix | Delete
function make_site_theme() {
[3300] Fix | Delete
// Name the theme after the blog.
[3301] Fix | Delete
$theme_name = __get_option( 'blogname' );
[3302] Fix | Delete
$template = sanitize_title( $theme_name );
[3303] Fix | Delete
$site_dir = WP_CONTENT_DIR . "/themes/$template";
[3304] Fix | Delete
[3305] Fix | Delete
// If the theme already exists, nothing to do.
[3306] Fix | Delete
if ( is_dir( $site_dir ) ) {
[3307] Fix | Delete
return false;
[3308] Fix | Delete
}
[3309] Fix | Delete
[3310] Fix | Delete
// We must be able to write to the themes dir.
[3311] Fix | Delete
if ( ! is_writable( WP_CONTENT_DIR . '/themes' ) ) {
[3312] Fix | Delete
return false;
[3313] Fix | Delete
}
[3314] Fix | Delete
[3315] Fix | Delete
umask( 0 );
[3316] Fix | Delete
if ( ! mkdir( $site_dir, 0777 ) ) {
[3317] Fix | Delete
return false;
[3318] Fix | Delete
}
[3319] Fix | Delete
[3320] Fix | Delete
if ( file_exists( ABSPATH . 'wp-layout.css' ) ) {
[3321] Fix | Delete
if ( ! make_site_theme_from_oldschool( $theme_name, $template ) ) {
[3322] Fix | Delete
// TODO: rm -rf the site theme directory.
[3323] Fix | Delete
return false;
[3324] Fix | Delete
}
[3325] Fix | Delete
} else {
[3326] Fix | Delete
if ( ! make_site_theme_from_default( $theme_name, $template ) ) {
[3327] Fix | Delete
// TODO: rm -rf the site theme directory.
[3328] Fix | Delete
return false;
[3329] Fix | Delete
}
[3330] Fix | Delete
}
[3331] Fix | Delete
[3332] Fix | Delete
// Make the new site theme active.
[3333] Fix | Delete
$current_template = __get_option( 'template' );
[3334] Fix | Delete
if ( WP_DEFAULT_THEME == $current_template ) {
[3335] Fix | Delete
update_option( 'template', $template );
[3336] Fix | Delete
update_option( 'stylesheet', $template );
[3337] Fix | Delete
}
[3338] Fix | Delete
return $template;
[3339] Fix | Delete
}
[3340] Fix | Delete
[3341] Fix | Delete
/**
[3342] Fix | Delete
* Translate user level to user role name.
[3343] Fix | Delete
*
[3344] Fix | Delete
* @since 2.0.0
[3345] Fix | Delete
*
[3346] Fix | Delete
* @param int $level User level.
[3347] Fix | Delete
* @return string User role name.
[3348] Fix | Delete
*/
[3349] Fix | Delete
function translate_level_to_role( $level ) {
[3350] Fix | Delete
switch ( $level ) {
[3351] Fix | Delete
case 10:
[3352] Fix | Delete
case 9:
[3353] Fix | Delete
case 8:
[3354] Fix | Delete
return 'administrator';
[3355] Fix | Delete
case 7:
[3356] Fix | Delete
case 6:
[3357] Fix | Delete
case 5:
[3358] Fix | Delete
return 'editor';
[3359] Fix | Delete
case 4:
[3360] Fix | Delete
case 3:
[3361] Fix | Delete
case 2:
[3362] Fix | Delete
return 'author';
[3363] Fix | Delete
case 1:
[3364] Fix | Delete
return 'contributor';
[3365] Fix | Delete
case 0:
[3366] Fix | Delete
default:
[3367] Fix | Delete
return 'subscriber';
[3368] Fix | Delete
}
[3369] Fix | Delete
}
[3370] Fix | Delete
[3371] Fix | Delete
/**
[3372] Fix | Delete
* Checks the version of the installed MySQL binary.
[3373] Fix | Delete
*
[3374] Fix | Delete
* @since 2.1.0
[3375] Fix | Delete
*
[3376] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3377] Fix | Delete
*/
[3378] Fix | Delete
function wp_check_mysql_version() {
[3379] Fix | Delete
global $wpdb;
[3380] Fix | Delete
$result = $wpdb->check_database_version();
[3381] Fix | Delete
if ( is_wp_error( $result ) ) {
[3382] Fix | Delete
wp_die( $result );
[3383] Fix | Delete
}
[3384] Fix | Delete
}
[3385] Fix | Delete
[3386] Fix | Delete
/**
[3387] Fix | Delete
* Disables the Automattic widgets plugin, which was merged into core.
[3388] Fix | Delete
*
[3389] Fix | Delete
* @since 2.2.0
[3390] Fix | Delete
*/
[3391] Fix | Delete
function maybe_disable_automattic_widgets() {
[3392] Fix | Delete
$plugins = __get_option( 'active_plugins' );
[3393] Fix | Delete
[3394] Fix | Delete
foreach ( (array) $plugins as $plugin ) {
[3395] Fix | Delete
if ( 'widgets.php' === basename( $plugin ) ) {
[3396] Fix | Delete
array_splice( $plugins, array_search( $plugin, $plugins, true ), 1 );
[3397] Fix | Delete
update_option( 'active_plugins', $plugins );
[3398] Fix | Delete
break;
[3399] Fix | Delete
}
[3400] Fix | Delete
}
[3401] Fix | Delete
}
[3402] Fix | Delete
[3403] Fix | Delete
/**
[3404] Fix | Delete
* Disables the Link Manager on upgrade if, at the time of upgrade, no links exist in the DB.
[3405] Fix | Delete
*
[3406] Fix | Delete
* @since 3.5.0
[3407] Fix | Delete
*
[3408] Fix | Delete
* @global int $wp_current_db_version The old (current) database version.
[3409] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3410] Fix | Delete
*/
[3411] Fix | Delete
function maybe_disable_link_manager() {
[3412] Fix | Delete
global $wp_current_db_version, $wpdb;
[3413] Fix | Delete
[3414] Fix | Delete
if ( $wp_current_db_version >= 22006 && get_option( 'link_manager_enabled' ) && ! $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) {
[3415] Fix | Delete
update_option( 'link_manager_enabled', 0 );
[3416] Fix | Delete
}
[3417] Fix | Delete
}
[3418] Fix | Delete
[3419] Fix | Delete
/**
[3420] Fix | Delete
* Runs before the schema is upgraded.
[3421] Fix | Delete
*
[3422] Fix | Delete
* @since 2.9.0
[3423] Fix | Delete
*
[3424] Fix | Delete
* @global int $wp_current_db_version The old (current) database version.
[3425] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3426] Fix | Delete
*/
[3427] Fix | Delete
function pre_schema_upgrade() {
[3428] Fix | Delete
global $wp_current_db_version, $wpdb;
[3429] Fix | Delete
[3430] Fix | Delete
// Upgrade versions prior to 2.9.
[3431] Fix | Delete
if ( $wp_current_db_version < 11557 ) {
[3432] Fix | Delete
// Delete duplicate options. Keep the option with the highest option_id.
[3433] Fix | Delete
$wpdb->query( "DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id" );
[3434] Fix | Delete
[3435] Fix | Delete
// Drop the old primary key and add the new.
[3436] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->options DROP PRIMARY KEY, ADD PRIMARY KEY(option_id)" );
[3437] Fix | Delete
[3438] Fix | Delete
// Drop the old option_name index. dbDelta() doesn't do the drop.
[3439] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->options DROP INDEX option_name" );
[3440] Fix | Delete
}
[3441] Fix | Delete
[3442] Fix | Delete
// Multisite schema upgrades.
[3443] Fix | Delete
if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) {
[3444] Fix | Delete
[3445] Fix | Delete
// Upgrade versions prior to 3.7.
[3446] Fix | Delete
if ( $wp_current_db_version < 25179 ) {
[3447] Fix | Delete
// New primary key for signups.
[3448] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" );
[3449] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->signups DROP INDEX domain" );
[3450] Fix | Delete
}
[3451] Fix | Delete
[3452] Fix | Delete
if ( $wp_current_db_version < 25448 ) {
[3453] Fix | Delete
// Convert archived from enum to tinyint.
[3454] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'" );
[3455] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0" );
[3456] Fix | Delete
}
[3457] Fix | Delete
}
[3458] Fix | Delete
[3459] Fix | Delete
// Upgrade versions prior to 4.2.
[3460] Fix | Delete
if ( $wp_current_db_version < 31351 ) {
[3461] Fix | Delete
if ( ! is_multisite() && wp_should_upgrade_global_tables() ) {
[3462] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
[3463] Fix | Delete
}
[3464] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX slug, ADD INDEX slug(slug(191))" );
[3465] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->terms DROP INDEX name, ADD INDEX name(name(191))" );
[3466] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->commentmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
[3467] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->postmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
[3468] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->posts DROP INDEX post_name, ADD INDEX post_name(post_name(191))" );
[3469] Fix | Delete
}
[3470] Fix | Delete
[3471] Fix | Delete
// Upgrade versions prior to 4.4.
[3472] Fix | Delete
if ( $wp_current_db_version < 34978 ) {
[3473] Fix | Delete
// If compatible termmeta table is found, use it, but enforce a proper index and update collation.
[3474] Fix | Delete
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->termmeta}'" ) && $wpdb->get_results( "SHOW INDEX FROM {$wpdb->termmeta} WHERE Column_name = 'meta_key'" ) ) {
[3475] Fix | Delete
$wpdb->query( "ALTER TABLE $wpdb->termmeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191))" );
[3476] Fix | Delete
maybe_convert_table_to_utf8mb4( $wpdb->termmeta );
[3477] Fix | Delete
}
[3478] Fix | Delete
}
[3479] Fix | Delete
}
[3480] Fix | Delete
[3481] Fix | Delete
if ( ! function_exists( 'install_global_terms' ) ) :
[3482] Fix | Delete
/**
[3483] Fix | Delete
* Install global terms.
[3484] Fix | Delete
*
[3485] Fix | Delete
* @since 3.0.0
[3486] Fix | Delete
*
[3487] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[3488] Fix | Delete
* @global string $charset_collate
[3489] Fix | Delete
*/
[3490] Fix | Delete
function install_global_terms() {
[3491] Fix | Delete
global $wpdb, $charset_collate;
[3492] Fix | Delete
$ms_queries = "
[3493] Fix | Delete
CREATE TABLE $wpdb->sitecategories (
[3494] Fix | Delete
cat_ID bigint(20) NOT NULL auto_increment,
[3495] Fix | Delete
cat_name varchar(55) NOT NULL default '',
[3496] Fix | Delete
category_nicename varchar(200) NOT NULL default '',
[3497] Fix | Delete
last_updated timestamp NOT NULL,
[3498] Fix | Delete
PRIMARY KEY (cat_ID),
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function