From 8460a0750dc91d2f31a082b1e1231f900269b0c2 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 27 Aug 2006 19:26:03 +0000 Subject: [PATCH] Handle posts with an empty cat list. fixes #3072 git-svn-id: http://svn.automattic.com/wordpress/trunk@4119 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index ae91c8e24b..7aa9ffe63c 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -759,7 +759,7 @@ function wp_publish_post($post_id) { function wp_set_post_categories($post_ID = 0, $post_categories = array()) { global $wpdb; // If $post_categories isn't already an array, make it one: - if (!is_array($post_categories) || 0 == count($post_categories)) + if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories)) $post_categories = array(get_option('default_category')); $post_categories = array_unique($post_categories); @@ -794,9 +794,10 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) { if ($add_cats) { foreach ($add_cats as $new_cat) { - $wpdb->query(" - INSERT INTO $wpdb->post2cat (post_id, category_id) - VALUES ($post_ID, $new_cat)"); + if ( !empty($new_cat) ) + $wpdb->query(" + INSERT INTO $wpdb->post2cat (post_id, category_id) + VALUES ($post_ID, $new_cat)"); } }