Make WordPress Core

Changeset 4738


Ignore:
Timestamp:
01/16/2007 01:54:50 AM (17 years ago)
Author:
ryan
Message:

Cleanup link upgrade code. Drop linkcategories table.

Location:
trunk
Files:
3 edited

Legend:

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

    r4612 r4738  
    509509                wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', array($post->ID));
    510510    }
     511
    511512    if ( $wp_current_db_version < 3570 ) {
    512513        // Create categories for link categories if a category with the same
    513514        // name doesn't exist.  Create a map of link cat IDs to cat IDs.
    514         $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
     515        $link_cat_id_map = array();
     516        $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM " . $wpdb->prefix . 'linkcategories');
    515517        foreach ( $link_cats as $link_cat) {
    516518            if ( $cat_id = category_exists($link_cat->cat_name) ) {
     
    526528        $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
    527529        if ( !empty($links) ) foreach ( $links as $link ) {
     530            if ( 0 == $link->link_category )
     531                continue;
     532            if ( ! isset($link_cat_id_map[$link->link_category]) )
     533                continue;
    528534            $link_cat = $link_cat_id_map[$link->link_category];
    529535            $cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = '$link->link_id' AND category_id = '$link_cat'");
    530             if (!$cat && 0 != $link->link_category) {
     536            if ( !$cat ) {
    531537                $wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id)
    532538                    VALUES ('$link->link_id', '$link_cat')");
     
    545551            }
    546552        }
     553
     554        // Obsolete linkcategories table
     555        $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories');
    547556    }
    548557}
  • trunk/wp-includes/wp-db.php

    r4686 r4738  
    2929    var $comments;
    3030    var $links;
    31     var $linkcategories;
    3231    var $options;
    3332    var $optiontypes;
  • trunk/wp-settings.php

    r4717 r4738  
    114114$wpdb->link2cat       = $wpdb->prefix . 'link2cat';
    115115$wpdb->links          = $wpdb->prefix . 'links';
    116 $wpdb->linkcategories = $wpdb->prefix . 'linkcategories';
    117116$wpdb->options        = $wpdb->prefix . 'options';
    118117$wpdb->postmeta       = $wpdb->prefix . 'postmeta';
Note: See TracChangeset for help on using the changeset viewer.