Cast to int

git-svn-id: http://svn.automattic.com/wordpress/trunk@5086 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-03-22 23:03:07 +00:00
parent 5b22739cac
commit 46fa88baf1
1 changed files with 6 additions and 3 deletions

View File

@ -460,6 +460,7 @@ function wp_get_recent_posts($num = 10) {
global $wpdb; global $wpdb;
// Set the limit clause, if we got a limit // Set the limit clause, if we got a limit
$num = (int) $num;
if ($num) { if ($num) {
$limit = "LIMIT $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()) { function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
global $wpdb; global $wpdb;
$post_ID = (int) $post_ID;
// If $post_categories isn't already an array, make it one: // If $post_categories isn't already an array, make it one:
if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories)) if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories))
$post_categories = array(get_option('default_category')); $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(" $old_categories = $wpdb->get_col("
SELECT category_id SELECT category_id
FROM $wpdb->post2cat FROM $wpdb->post2cat
WHERE post_id = $post_ID"); WHERE post_id = '$post_ID'");
if (!$old_categories) { if (!$old_categories) {
$old_categories = array(); $old_categories = array();
@ -795,8 +798,8 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
foreach ($delete_cats as $del) { foreach ($delete_cats as $del) {
$wpdb->query(" $wpdb->query("
DELETE FROM $wpdb->post2cat DELETE FROM $wpdb->post2cat
WHERE category_id = $del WHERE category_id = '$del'
AND post_id = $post_ID AND post_id = '$post_ID'
"); ");
} }
} }