Don't dupe categories when adding new ones, use the existing ID.

git-svn-id: http://svn.automattic.com/wordpress/trunk@5148 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2007-03-31 05:22:10 +00:00
parent 3124054b45
commit 2706ae78bd
1 changed files with 4 additions and 0 deletions

View File

@ -121,6 +121,10 @@ function wp_insert_category($catarr) {
else
$links_private = 0;
// Let's check if we have this category already, if so just do an update
if ( $cat_ID = $wpdb->get_var( "SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename' " ) )
$update = true;
if (!$update) {
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
$cat_ID = (int) $wpdb->insert_id;