Make WordPress Core

Changeset 12933


Ignore:
Timestamp:
02/03/2010 01:00:57 AM (15 years ago)
Author:
wpmuguru
Message:

fix potential global terms inconsistency, props rboren, see #11644

Location:
trunk
Files:
3 edited

Legend:

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

    r12920 r12933  
    657657    if ( !is_multisite() ) {
    658658
    659         /* translators: Default category slug */
    660         $cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) );
    661 
    662         $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => 1, 'cat_name' => __('Uncategorized'), 'category_nicename' => $cat_slug, 'last_updated' => current_time( 'mysql', true ) ) );
    663 
    664         /* translators: Default link category slug */
    665         $cat_slug = sanitize_title( _x( 'Blogroll', 'Default link category slug' ) );
    666 
    667         $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => 2, 'cat_name' => __('Blogroll'), 'category_nicename' => $cat_slug, 'last_updated' => current_time( 'mysql', true ) ) );
    668         $wpdb->query( "INSERT INTO $wpdb->sitecategories (cat_id, cat_name, category_nicename, last_updated) SELECT term_id, `name`, slug, NOW() FROM $wpdb->terms WHERE term_id > 2" );
     659        $wpdb->query( "INSERT INTO $wpdb->sitecategories (cat_id, cat_name, category_nicename, last_updated) SELECT term_id, `name`, slug, NOW() FROM $wpdb->terms" );
    669660
    670661        $site_admins = array( $site_user->user_login );
  • trunk/wp-admin/includes/upgrade.php

    r12931 r12933  
    104104    $cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
    105105
    106     $wpdb->insert( $wpdb->terms, array('name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
    107     $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => '1', 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
     106    if ( is_multisite() ) {
     107        $cat_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
     108        if ( $cat_id == null ) {
     109            $wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
     110            $cat_id = $wpdb->insert_id;
     111        }
     112        update_option('default_category', $cat_id);
     113    } else {
     114        $cat_id = 1;
     115    }
     116
     117    $wpdb->insert( $wpdb->terms, array('term_id' => $cat_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
     118    $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $cat_id, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
     119    $cat_tt_id = $wpdb->insert_id;
    108120
    109121    // Default link category
     
    112124    $cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
    113125
    114     $wpdb->insert( $wpdb->terms, array('name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
    115     $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => '2', 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
     126    if ( is_multisite() ) {
     127        $blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
     128        if ( $blogroll_id == null ) {
     129            $wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
     130            $blogroll_id = $wpdb->insert_id;
     131        }
     132        update_option('default_link_category', $blogroll_id);
     133    } else {
     134        $blogroll_id = 2;
     135    }
     136
     137    $wpdb->insert( $wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
     138    $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
     139    $blogroll_tt_id = $wpdb->insert_id;
    116140
    117141    // Now drop in some default links
     
    154178    foreach ( $default_links as $link ) {
    155179        $wpdb->insert( $wpdb->links, $link);
    156         $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => 2, 'object_id' => $wpdb->insert_id) );
     180        $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $blogroll_tt_id, 'object_id' => $wpdb->insert_id) );
    157181    }
    158182
     
    191215                                'post_content_filtered' => ''
    192216                                ));
    193     $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => 1, 'object_id' => 1) );
     217    $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
    194218
    195219    // Default comment
  • trunk/wp-includes/ms-functions.php

    r12932 r12933  
    14201420    $wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') );
    14211421
    1422     // Default category
    1423     $wpdb->insert( $wpdb->terms, array('term_id' => 1, 'name' => __('Uncategorized'), 'slug' => sanitize_title(__('Uncategorized')), 'term_group' => 0) );
    1424     $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => 1, 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1) );
    1425 
    1426     // Default link category
    1427     $cat_name = __('Blogroll');
    1428     $cat_slug = sanitize_title($cat_name);
    1429 
    1430     $blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
    1431 
    1432     if ( $blogroll_id == null ) {
    1433         $wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
    1434         $blogroll_id = $wpdb->insert_id;
    1435     }
    1436     $wpdb->insert( $wpdb->terms, array('term_id' => $blogroll_id, 'name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
    1437     $wpdb->insert( $wpdb->term_taxonomy, array('term_id' => $blogroll_id, 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 2) );
    1438     update_option('default_link_category', $blogroll_id);
    1439 
    14401422    // remove all perms
    14411423    $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE meta_key = %s", $table_prefix.'user_level') );
Note: See TracChangeset for help on using the changeset viewer.