WordPress.org

Make WordPress Core

Ticket #2699: 2699.2.diff

File 2699.2.diff, 1.9 KB (added by Denis-de-Bernardy, 6 years ago)

similar to Ryan's patch without the unneeded wp_cache delete

  • wp-includes/version.php

     
    1515 * 
    1616 * @global int $wp_db_version 
    1717 */ 
    18 $wp_db_version = 11548; 
     18$wp_db_version = 11557; 
    1919 
    2020/** 
    2121 * Holds the TinyMCE version 
  • wp-admin/includes/upgrade.php

     
    269269 
    270270        wp_check_mysql_version(); 
    271271        wp_cache_flush(); 
     272        pre_schema_upgrade(); 
    272273        make_db_current_silent(); 
    273274        upgrade_all(); 
    274275        wp_cache_flush(); 
     
    16561657        } 
    16571658} 
    16581659 
    1659 ?> 
     1660/** 
     1661 * Runs before the schema is upgraded. 
     1662 */ 
     1663function pre_schema_upgrade() { 
     1664        global $wp_current_db_version, $wp_db_version, $wpdb; 
     1665 
     1666        // Only run if less than 2.9 
     1667        if ( $wp_current_db_version >= 11557 ) 
     1668                return; 
     1669 
     1670        // Delete duplicate options.  Keep the option with the highest option_id. 
     1671        $delete_options = $wpdb->get_col("SELECT o1.option_id FROM wp_options AS o1 JOIN wp_options AS o2 ON o2.option_name = o1.option_name AND o2.option_id > o1.option_id"); 
     1672        if ( empty($delete_options) ) 
     1673                return; 
     1674 
     1675        $delete_options = implode("', '", $delete_options); 
     1676        $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($delete_options)"); 
     1677} 
     1678 
     1679?> 
     1680 No newline at end of file 
  • wp-admin/includes/schema.php

     
    100100  option_value longtext NOT NULL, 
    101101  autoload varchar(20) NOT NULL default 'yes', 
    102102  PRIMARY KEY  (option_id,blog_id,option_name), 
    103   KEY option_name (option_name) 
     103  UNIQUE KEY name (option_name) 
    104104) $charset_collate; 
    105105CREATE TABLE $wpdb->postmeta ( 
    106106  meta_id bigint(20) unsigned NOT NULL auto_increment,