diff --git a/wp-includes/post.php b/wp-includes/post.php index aa5b7ef91..a3c50f428 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -460,6 +460,7 @@ function wp_get_recent_posts($num = 10) { global $wpdb; // Set the limit clause, if we got a limit + $num = (int) $num; if ($num) { $limit = "LIMIT $num"; } @@ -770,6 +771,8 @@ function wp_publish_post($post_id) { function wp_set_post_categories($post_ID = 0, $post_categories = array()) { global $wpdb; + + $post_ID = (int) $post_ID; // If $post_categories isn't already an array, make it one: if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories)) $post_categories = array(get_option('default_category')); @@ -780,7 +783,7 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) { $old_categories = $wpdb->get_col(" SELECT category_id FROM $wpdb->post2cat - WHERE post_id = $post_ID"); + WHERE post_id = '$post_ID'"); if (!$old_categories) { $old_categories = array(); @@ -795,8 +798,8 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) { foreach ($delete_cats as $del) { $wpdb->query(" DELETE FROM $wpdb->post2cat - WHERE category_id = $del - AND post_id = $post_ID + WHERE category_id = '$del' + AND post_id = '$post_ID' "); } }