From 2706ae78bd385c2249149a6ee5ccaac9a6f84282 Mon Sep 17 00:00:00 2001 From: matt Date: Sat, 31 Mar 2007 05:22:10 +0000 Subject: [PATCH] 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 --- wp-admin/admin-db.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php index 314892a225..de8a689f22 100644 --- a/wp-admin/admin-db.php +++ b/wp-admin/admin-db.php @@ -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;