Quote values heading to DB. Cast some ints.

git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@5031 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-03-12 21:28:43 +00:00
parent 4ac2b6d88d
commit fda7688049

View File

@ -512,12 +512,14 @@ function wp_set_post_cats($blogid = '1', $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)");
$new_cat = (int) $new_cat;
if ( !empty($new_cat) )
$wpdb->query("
INSERT INTO $wpdb->post2cat (post_id, category_id)
VALUES ('$post_ID', '$new_cat')");
}
}
// Update category counts.
$all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
foreach ( $all_affected_cats as $cat_id ) {