WordPress.org

Make WordPress Core

Changeset 12560


Ignore:
Timestamp:
12/28/2009 04:25:56 PM (11 years ago)
Author:
ryan
Message:

Better duplicate option delete query. Props miqrogroove. fixes #11649 for trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/upgrade.php

    r12513 r12560  
    16891689    if ( $wp_current_db_version < 11557 ) {
    16901690        // Delete duplicate options.  Keep the option with the highest option_id.
    1691         $delete_options = $wpdb->get_col("SELECT o1.option_id FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 ON o2.option_name = o1.option_name AND o2.option_id > o1.option_id");
    1692         if ( !empty($delete_options) ) {
    1693             $delete_options = implode(',', $delete_options);
    1694             $wpdb->query("DELETE FROM $wpdb->options WHERE option_id IN ($delete_options)");
    1695         }
     1691        $wpdb->query("DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id");
    16961692
    16971693        // Drop the old primary key and add the new.
Note: See TracChangeset for help on using the changeset viewer.