Some int casts

git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@5099 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2007-03-25 23:06:28 +00:00
parent bbd24106bd
commit a359d5977b
7 changed files with 53 additions and 51 deletions

View File

@ -110,7 +110,7 @@ function wp_insert_category($catarr) {
if (!$update) {
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
$cat_ID = $wpdb->insert_id;
$cat_ID = (int) $wpdb->insert_id;
} else {
$wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'");
}
@ -207,7 +207,7 @@ function category_exists($cat_name) {
if (!$category_nicename = sanitize_title($cat_name))
return 0;
return $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'");
}
function wp_delete_user($id, $reassign = 'novalue') {
@ -270,6 +270,8 @@ function wp_insert_link($linkdata) {
if ( !empty($link_id) )
$update = true;
$link_id = (int) $link_id;
if( trim( $link_name ) == '' )
return 0;
$link_name = apply_filters('pre_link_name', $link_name);
@ -326,7 +328,7 @@ function wp_insert_link($linkdata) {
WHERE link_id='$link_id'");
} else {
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
$link_id = $wpdb->insert_id;
$link_id = (int) $wpdb->insert_id;
}
if ( $update )

View File

@ -44,7 +44,7 @@ if ( !empty( $_POST['delete_comments'] ) ) :
$i = 0;
foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
$comment = (int) $comment;
$post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
$post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
$authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
if ( current_user_can('edit_post', $post_id) ) :
wp_set_comment_status($comment, "delete");

View File

@ -430,8 +430,8 @@ class Dotclear_Import {
extract($comment);
// WordPressify Data
$comment_ID = ltrim($comment_id, '0');
$comment_post_ID = $postarr[$post_id];
$comment_ID = (int) ltrim($comment_id, '0');
$comment_post_ID = (int) $postarr[$post_id];
$comment_approved = "$comment_pub";
$name = $wpdb->escape(csc ($comment_auteur));
$email = $wpdb->escape($comment_email);

View File

@ -80,7 +80,7 @@ class LJ_Import {
$comments = $comments[1];
if ( $comments ) {
$comment_post_ID = $post_id;
$comment_post_ID = (int) $post_id;
$num_comments = 0;
foreach ($comments as $comment) {
preg_match('|<event>(.*?)</event>|is', $comment, $comment_content);

View File

@ -169,7 +169,7 @@ class MT_Import {
return;
}
$this->file = $file['file'];
$this->id = $file['id'];
$this->id = (int) $file['id'];
$this->get_entries();
$this->mt_authors_form();
@ -293,7 +293,7 @@ class MT_Import {
}
}
$comment_post_ID = $post_id;
$comment_post_ID = (int) $post_id;
$comment_approved = 1;
// Now for comments

View File

@ -84,7 +84,7 @@ if ( !empty($tb_url) && !empty($title) && !empty($tb_url) ) {
$title = (strlen($title) > 250) ? substr($title, 0, 250) . '...' : $title;
}
$comment_post_ID = $tb_id;
$comment_post_ID = (int) $tb_id;
$comment_author = $blog_name;
$comment_author_email = '';
$comment_author_url = $tb_url;

View File

@ -208,9 +208,9 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$post_ID = $args[1];
$user_login = $args[2];
$user_pass = $args[3];
$post_ID = (int) $args[1];
$user_login = $args[2];
$user_pass = $args[3];
if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
@ -243,10 +243,10 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$blog_ID = $args[1]; /* though we don't use it yet */
$user_login = $args[2];
$user_pass = $args[3];
$num_posts = $args[4];
$blog_ID = (int) $args[1]; /* though we don't use it yet */
$user_login = $args[2];
$user_pass = $args[3];
$num_posts = $args[4];
if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
@ -291,7 +291,7 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$blog_ID = $args[1];
$blog_ID = (int) $args[1];
$user_login = $args[2];
$user_pass = $args[3];
$template = $args[4]; /* could be 'main' or 'archiveIndex', but we don't use it */
@ -325,7 +325,7 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$blog_ID = $args[1];
$blog_ID = (int) $args[1];
$user_login = $args[2];
$user_pass = $args[3];
$content = $args[4];
@ -362,7 +362,7 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$blog_ID = $args[1]; /* though we don't use it yet */
$blog_ID = (int) $args[1]; /* though we don't use it yet */
$user_login = $args[2];
$user_pass = $args[3];
$content = $args[4];
@ -459,7 +459,7 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$post_ID = $args[1];
$post_ID = (int) $args[1];
$user_login = $args[2];
$user_pass = $args[3];
$publish = $args[4];
@ -500,7 +500,7 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$blog_ID = $args[0]; // we will support this in the near future
$blog_ID = (int) $args[0]; // we will support this in the near future
$user_login = $args[1];
$user_pass = $args[2];
$content_struct = $args[3];
@ -668,7 +668,7 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$post_ID = $args[0];
$post_ID = (int) $args[0];
$user_login = $args[1];
$user_pass = $args[2];
@ -723,10 +723,10 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$blog_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$num_posts = $args[3];
$blog_ID = (int) $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$num_posts = (int) $args[3];
if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
@ -789,9 +789,9 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$blog_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$blog_ID = (int) $args[0];
$user_login = $args[1];
$user_pass = $args[2];
if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
@ -823,7 +823,7 @@ class wp_xmlrpc_server extends IXR_Server {
global $wpdb;
$blog_ID = $wpdb->escape($args[0]);
$blog_ID = (int) $args[0];
$user_login = $wpdb->escape($args[1]);
$user_pass = $wpdb->escape($args[2]);
$data = $args[3];
@ -863,10 +863,10 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$blog_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$num_posts = $args[3];
$blog_ID = (int) $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$num_posts = (int) $args[3];
if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
@ -908,9 +908,9 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$blog_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$blog_ID = (int) $args[0];
$user_login = $args[1];
$user_pass = $args[2];
if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
@ -937,9 +937,9 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$post_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$post_ID = (int) $args[0];
$user_login = $args[1];
$user_pass = $args[2];
if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
@ -967,10 +967,10 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$post_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$categories = $args[3];
$post_ID = (int) $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$categories = $args[3];
if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
@ -1050,9 +1050,9 @@ class wp_xmlrpc_server extends IXR_Server {
$this->escape($args);
$post_ID = $args[0];
$user_login = $args[1];
$user_pass = $args[2];
$post_ID = (int) $args[0];
$user_login = $args[1];
$user_pass = $args[2];
if (!$this->login_pass_ok($user_login, $user_pass)) {
return $this->error;
@ -1112,18 +1112,18 @@ class wp_xmlrpc_server extends IXR_Server {
} elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) {
// the path defines the post_ID (archives/p/XXXX)
$blah = explode('/', $match[0]);
$post_ID = $blah[1];
$post_ID = (int) $blah[1];
$way = 'from the path';
} elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) {
// the querystring defines the post_ID (?p=XXXX)
$blah = explode('=', $match[0]);
$post_ID = $blah[1];
$post_ID = (int) $blah[1];
$way = 'from the querystring';
} elseif (isset($urltest['fragment'])) {
// an #anchor is there, it's either...
if (intval($urltest['fragment'])) {
// ...an integer #XXXX (simpliest case)
$post_ID = $urltest['fragment'];
$post_ID = (int) $urltest['fragment'];
$way = 'from the fragment (numeric)';
} elseif (preg_match('/post-[0-9]+/',$urltest['fragment'])) {
// ...a post id in the form 'post-###'