Permalink
Browse files

Big int patch for 2.1

git-svn-id: http://svn.automattic.com/wordpress/branches/2.1@5092 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent d066cef commit 207af1aeb167af9e2fd53d277ba8e3f3e6c9e185 ryan committed Mar 23, 2007
View
@@ -231,7 +231,7 @@ function wp_ajax_meta_row( $pid, $mid, $key, $value ) {
if($_POST['post_ID'] < 0) {
$_POST['temp_ID'] = $_POST['post_ID'];
$id = wp_write_post();
- if(is_wp_error($id))
+ if( is_wp_error($id) )
die($id->get_error_message());
else
die("$id");
View
@@ -123,7 +123,7 @@ function wp_insert_category($catarr) {
if (!$update) {
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
- $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', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
}
@@ -245,7 +245,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') {
@@ -299,6 +299,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);
@@ -360,7 +362,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_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$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;
}
wp_set_link_cats($link_id, $link_category);
@@ -443,7 +445,7 @@ function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
$old_categories = $wpdb->get_col("
SELECT category_id
FROM $wpdb->link2cat
- WHERE link_id = $link_ID");
+ WHERE link_id = '$link_ID'");
if (!$old_categories) {
$old_categories = array();
@@ -456,10 +458,11 @@ function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
if ($delete_cats) {
foreach ($delete_cats as $del) {
+ $del = (int) $del;
$wpdb->query("
DELETE FROM $wpdb->link2cat
- WHERE category_id = $del
- AND link_id = $link_ID
+ WHERE category_id = '$del'
+ AND link_id = '$link_ID'
");
}
}
@@ -151,7 +151,7 @@ function fix_attachment_links( $post_ID ) {
if ( 0 == preg_match( $search, $anchor, $id_matches ) )
continue;
- $id = $id_matches[3];
+ $id = (int) $id_matches[3];
// While we have the attachment ID, let's adopt any orphans.
$attachment = & get_post( $id, ARRAY_A );
@@ -435,7 +435,7 @@ function get_user_to_edit( $user_id ) {
function add_user() {
if ( func_num_args() ) { // The hackiest hack that ever did hack
global $current_user, $wp_roles;
- $user_id = func_get_arg( 0 );
+ $user_id = (int) func_get_arg( 0 );
if ( isset( $_POST['role'] ) ) {
if( $user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap( 'edit_users' ) ) {
@@ -453,7 +453,7 @@ function edit_user( $user_id = 0 ) {
global $current_user, $wp_roles, $wpdb;
if ( $user_id != 0 ) {
$update = true;
- $user->ID = $user_id;
+ $user->ID = (int) $user_id;
$userdata = get_userdata( $user_id );
$user->user_login = $wpdb->escape( $userdata->user_login );
} else {
@@ -781,8 +781,8 @@ function _cat_row( $category, $level, $name_override = false ) {
$pad = str_repeat( '&#8212; ', $level );
if ( current_user_can( 'manage_categories' ) ) {
$edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__( 'Edit' )."</a></td>";
- $default_cat_id = get_option( 'default_category' );
- $default_link_cat_id = get_option( 'default_link_category' );
+ $default_cat_id = (int) get_option( 'default_category' );
+ $default_link_cat_id = (int) get_option( 'default_link_category' );
if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id ) )
$edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . js_escape(sprintf( __("You are about to delete the category '%s'.\nAll of its posts will go into the default category of '%s'\nAll of its bookmarks will go into the default category of '%s'.\n'OK' to delete, 'Cancel' to stop." ), $category->cat_name, get_catname( $default_cat_id ), get_catname( $default_link_cat_id ) )) . "' );\" class='delete'>".__( 'Delete' )."</a>";
@@ -821,7 +821,7 @@ function page_rows( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) {
$post->post_title = wp_specialchars( $post->post_title );
$pad = str_repeat( '&#8212; ', $level );
- $id = $post->ID;
+ $id = (int) $post->ID;
$class = ('alternate' == $class ) ? '' : 'alternate';
?>
<tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
@@ -56,7 +56,7 @@ function getNumChecked(form)
$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) ) {
if ( !empty( $_POST['spam_button'] ) )
@@ -104,7 +104,7 @@ function import_posts() {
$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('|<body>(.*?)</body>|is', $comment, $comment_content);
@@ -437,8 +437,8 @@ function comments2wp($comments='')
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);
@@ -82,7 +82,7 @@ function import_posts() {
$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
@@ -171,7 +171,7 @@ function select_authors() {
return;
}
$this->file = $file['file'];
- $this->id = $file['id'];
+ $this->id = (int) $file['id'];
$this->get_entries();
$this->mt_authors_form();
@@ -295,7 +295,7 @@ function process_posts() {
}
}
- $comment_post_ID = $post_id;
+ $comment_post_ID = (int) $post_id;
$comment_approved = 1;
// Now for comments
@@ -174,7 +174,7 @@ function select_authors() {
return;
}
$this->file = $file['file'];
- $this->id = $file['id'];
+ $this->id = (int) $file['id'];
$this->get_entries();
$this->wp_authors_form();
@@ -201,7 +201,7 @@ function process_categories() {
if ( empty($parent) )
$category_parent = '0';
else
- $category_parent = (int) category_exists($parent);
+ $category_parent = category_exists($parent);
$catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name');
@@ -144,7 +144,7 @@ function the_author_posts_link($deprecated = '') {
function get_author_posts_url($author_id, $author_nicename = '') {
global $wpdb, $wp_rewrite, $post, $cache_userdata;
- $auth_ID = $author_id;
+ $auth_ID = (int) $author_id;
$link = $wp_rewrite->get_author_permastruct();
if ( empty($link) ) {
@@ -165,7 +165,7 @@ function get_linkcatname($id = 0) {
if ( empty($cats) || ! is_array($cats) )
return '';
- $cat_id = $cats[0]; // Take the first cat.
+ $cat_id = (int) $cats[0]; // Take the first cat.
$cat = get_category($cat_id);
return $cat->cat_name;
@@ -64,7 +64,7 @@ function get_the_category($id = false) {
$id = (int) $id;
if ( !$id )
- $id = $post->ID;
+ $id = (int) $post->ID;
if ( !isset($category_cache[$blog_id][$id]) )
update_post_category_cache($id);
@@ -150,7 +150,7 @@ function get_comments_number( $post_id = 0 ) {
$post_id = (int) $post_id;
if ( !$post_id )
- $post_id = $id;
+ $post_id = (int) $id;
$post = get_post($post_id);
if ( ! isset($post->comment_count) )
View
@@ -345,7 +345,7 @@ function wp_insert_comment($commentdata) {
('$comment_post_ID', '$comment_author', '$comment_author_email', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content', '$comment_approved', '$comment_agent', '$comment_type', '$comment_parent', '$user_id')
");
- $id = $wpdb->insert_id;
+ $id = (int) $wpdb->insert_id;
if ( $comment_approved == 1)
wp_update_comment_count($comment_post_ID);
View
@@ -108,7 +108,7 @@ function comments_rss($commentsrssfilename = '') {
function get_author_rss_link($echo = false, $author_id, $author_nicename) {
- $auth_ID = $author_id;
+ $auth_ID = (int) $author_id;
$permalink_structure = get_option('permalink_structure');
if ( '' == $permalink_structure ) {
@@ -566,7 +566,7 @@ function update_post_category_cache($post_ids) {
$post_id_array = (array) explode(',', $post_ids);
$count = count( $post_id_array);
for ( $i = 0; $i < $count; $i++ ) {
- $post_id = $post_id_array[ $i ];
+ $post_id = (int) $post_id_array[ $i ];
if ( isset( $category_cache[$blog_id][$post_id] ) ) {
unset( $post_id_array[ $i ] );
continue;
@@ -620,7 +620,7 @@ function update_postmeta_cache($post_id_list = '') {
$post_id_array = (array) explode(',', $post_id_list);
$count = count( $post_id_array);
for ( $i = 0; $i < $count; $i++ ) {
- $post_id = $post_id_array[ $i ];
+ $post_id = (int) $post_id_array[ $i ];
if ( isset( $post_meta_cache[$blog_id][$post_id] ) ) { // If the meta is already cached
unset( $post_id_array[ $i ] );
continue;
@@ -95,7 +95,7 @@ function get_page_link($id = false) {
$id = (int) $id;
if ( !$id )
- $id = $post->ID;
+ $id = (int) $post->ID;
if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
$link = get_option('home');
@@ -110,7 +110,7 @@ function _get_page_link( $id = false ) {
global $post, $wp_rewrite;
if ( !$id )
- $id = $post->ID;
+ $id = (int) $post->ID;
$pagestruct = $wp_rewrite->get_page_permastruct();
@@ -131,7 +131,7 @@ function get_attachment_link($id = false) {
$link = false;
if (! $id) {
- $id = $post->ID;
+ $id = (int) $post->ID;
}
$object = get_post($id);
@@ -473,7 +473,7 @@ function wp_new_user_notification($user_id, $plaintext_pass = '') {
if ( !function_exists('wp_verify_nonce') ) :
function wp_verify_nonce($nonce, $action = -1) {
$user = wp_get_current_user();
- $uid = $user->id;
+ $uid = (int) $user->id;
$i = ceil(time() / 43200);
@@ -487,7 +487,7 @@ function wp_verify_nonce($nonce, $action = -1) {
if ( !function_exists('wp_create_nonce') ) :
function wp_create_nonce($action = -1) {
$user = wp_get_current_user();
- $uid = $user->id;
+ $uid = (int) $user->id;
$i = ceil(time() / 43200);
View
@@ -375,7 +375,7 @@ function get_post_custom($post_id = 0) {
global $id, $post_meta_cache, $wpdb, $blog_id;
if ( !$post_id )
- $post_id = $id;
+ $post_id = (int) $id;
$post_id = (int) $post_id;
@@ -539,7 +539,7 @@ function wp_insert_post($postarr = array()) {
// Get the post ID.
if ( $update )
- $post_ID = $ID;
+ $post_ID = (int) $ID;
// Create a valid post name. Drafts are allowed to have an empty
// post name.
@@ -643,7 +643,7 @@ function wp_insert_post($postarr = array()) {
(post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type)
VALUES
('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$post_type', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type')");
- $post_ID = $wpdb->insert_id;
+ $post_ID = (int) $wpdb->insert_id;
}
if ( empty($post_name) && 'draft' != $post_status ) {
@@ -1254,7 +1254,7 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
$update = false;
if ( !empty($ID) ) {
$update = true;
- $post_ID = $ID;
+ $post_ID = (int) $ID;
}
// Create a valid post name.
@@ -1349,7 +1349,7 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
(post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid)
VALUES
('$post_author', '$post_date', '$post_date_gmt', '$post_content', '$post_content_filtered', '$post_title', '$post_excerpt', '$post_status', '$post_type', '$comment_status', '$ping_status', '$post_password', '$post_name', '$to_ping', '$pinged', '$post_date', '$post_date_gmt', '$post_parent', '$menu_order', '$post_mime_type', '$guid')");
- $post_ID = $wpdb->insert_id;
+ $post_ID = (int) $wpdb->insert_id;
}
if ( empty($post_name) ) {
@@ -1504,7 +1504,7 @@ function wp_mime_type_icon( $mime = 0 ) {
$mime = (int) $mime;
if ( !$post =& get_post( $mime ) )
return false;
- $post_id = $post->ID;
+ $post_id = (int) $post->ID;
$mime = $post->post_mime_type;
}
@@ -89,15 +89,15 @@ function wp_insert_user($userdata) {
$query = "UPDATE $wpdb->users SET user_pass='$user_pass', user_email='$user_email', user_url='$user_url', user_nicename = '$user_nicename', display_name = '$display_name' WHERE ID = '$ID'";
$query = apply_filters('update_user_query', $query);
$wpdb->query( $query );
- $user_id = $ID;
+ $user_id = (int) $ID;
} else {
$query = "INSERT INTO $wpdb->users
(user_login, user_pass, user_email, user_url, user_registered, user_nicename, display_name)
VALUES
('$user_login', '$user_pass', '$user_email', '$user_url', '$user_registered', '$user_nicename', '$display_name')";
$query = apply_filters('create_user_query', $query);
$wpdb->query( $query );
- $user_id = $wpdb->insert_id;
+ $user_id = (int) $wpdb->insert_id;
}
update_usermeta( $user_id, 'first_name', $first_name);
View
@@ -345,7 +345,7 @@ function get_home_template() {
function get_page_template() {
global $wp_query;
- $id = $wp_query->post->ID;
+ $id = (int) $wp_query->post->ID;
$template = get_post_meta($id, '_wp_page_template', true);
if ( 'default' == $template )
View
@@ -161,8 +161,8 @@ function setup_userdata($user_id = '') {
$userdata = $user->data;
$user_login = $user->user_login;
- $user_level = $user->user_level;
- $user_ID = $user->ID;
+ $user_level = (int) $user->user_level;
+ $user_ID = (int) $user->ID;
$user_email = $user->user_email;
$user_url = $user->user_url;
$user_pass_md5 = md5($user->user_pass);
Oops, something went wrong.

0 comments on commit 207af1a

Please sign in to comment.