Changeset 5092

Show
Ignore:
Timestamp:
03/23/07 03:18:00 (1 year ago)
Author:
ryan
Message:

Big int patch for 2.1

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.1/wp-admin/admin-ajax.php

    r4883 r5092  
    232232        $_POST['temp_ID'] = $_POST['post_ID']; 
    233233        $id = wp_write_post(); 
    234         if(is_wp_error($id)
     234        if( is_wp_error($id)
    235235            die($id->get_error_message()); 
    236236        else 
  • branches/2.1/wp-admin/admin-db.php

    r5030 r5092  
    124124    if (!$update) { 
    125125        $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')"); 
    126         $cat_ID = $wpdb->insert_id; 
     126        $cat_ID = (int) $wpdb->insert_id; 
    127127    } else { 
    128128        $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'"); 
     
    246246        return 0; 
    247247 
    248     return $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'"); 
     248    return (int) $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE category_nicename = '$category_nicename'"); 
    249249} 
    250250 
     
    299299    if ( !empty($link_id) ) 
    300300        $update = true; 
     301 
     302    $link_id = (int) $link_id; 
    301303 
    302304    if( trim( $link_name ) == '' ) 
     
    361363    } else { 
    362364        $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')"); 
    363         $link_id = $wpdb->insert_id; 
     365        $link_id = (int) $wpdb->insert_id; 
    364366    } 
    365367 
     
    444446        SELECT category_id 
    445447        FROM $wpdb->link2cat 
    446         WHERE link_id = $link_ID"); 
     448        WHERE link_id = '$link_ID'"); 
    447449 
    448450    if (!$old_categories) { 
     
    457459    if ($delete_cats) { 
    458460        foreach ($delete_cats as $del) { 
     461            $del = (int) $del; 
    459462            $wpdb->query(" 
    460463                DELETE FROM $wpdb->link2cat 
    461                 WHERE category_id = $del 
    462                     AND link_id = $link_ID 
     464                WHERE category_id = '$del' 
     465                    AND link_id = '$link_ID' 
    463466                "); 
    464467        } 
  • branches/2.1/wp-admin/admin-functions.php

    r5073 r5092  
    152152            continue; 
    153153 
    154         $id = $id_matches[3]; 
     154        $id = (int) $id_matches[3]; 
    155155 
    156156        // While we have the attachment ID, let's adopt any orphans. 
     
    436436    if ( func_num_args() ) { // The hackiest hack that ever did hack 
    437437        global $current_user, $wp_roles; 
    438         $user_id = func_get_arg( 0 ); 
     438        $user_id = (int) func_get_arg( 0 ); 
    439439 
    440440        if ( isset( $_POST['role'] ) ) { 
     
    454454    if ( $user_id != 0 ) { 
    455455        $update = true; 
    456         $user->ID = $user_id; 
     456        $user->ID = (int) $user_id; 
    457457        $userdata = get_userdata( $user_id ); 
    458458        $user->user_login = $wpdb->escape( $userdata->user_login ); 
     
    782782    if ( current_user_can( 'manage_categories' ) ) { 
    783783        $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__( 'Edit' )."</a></td>"; 
    784         $default_cat_id = get_option( 'default_category' ); 
    785         $default_link_cat_id = get_option( 'default_link_category' ); 
     784        $default_cat_id = (int) get_option( 'default_category' ); 
     785        $default_link_cat_id = (int) get_option( 'default_link_category' ); 
    786786 
    787787        if ( ($category->cat_ID != $default_cat_id ) && ($category->cat_ID != $default_link_cat_id ) ) 
     
    822822        $post->post_title = wp_specialchars( $post->post_title ); 
    823823        $pad = str_repeat( '&#8212; ', $level ); 
    824         $id = $post->ID; 
     824        $id = (int) $post->ID; 
    825825        $class = ('alternate' == $class ) ? '' : 'alternate'; 
    826826?> 
  • branches/2.1/wp-admin/edit-comments.php

    r5057 r5092  
    5757    foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each 
    5858        $comment = (int) $comment; 
    59         $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment"); 
     59        $post_id = (int) $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment"); 
    6060        // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") ); 
    6161        if ( current_user_can('edit_post', $post_id) ) { 
  • branches/2.1/wp-admin/import/blogware.php

    r4495 r5092  
    105105 
    106106            if ( $comments ) { 
    107                 $comment_post_ID = $post_id; 
     107                $comment_post_ID = (int) $post_id; 
    108108                $num_comments = 0; 
    109109                foreach ($comments as $comment) { 
  • branches/2.1/wp-admin/import/dotclear.php

    r4608 r5092  
    438438 
    439439                // WordPressify Data 
    440                 $comment_ID = ltrim($comment_id, '0'); 
    441                 $comment_post_ID = $postarr[$post_id]; 
     440                $comment_ID = (int) ltrim($comment_id, '0'); 
     441                $comment_post_ID = (int) $postarr[$post_id]; 
    442442                $comment_approved = "$comment_pub"; 
    443443                $name = $wpdb->escape(csc ($comment_auteur)); 
  • branches/2.1/wp-admin/import/livejournal.php

    r4608 r5092  
    8383 
    8484            if ( $comments ) { 
    85                 $comment_post_ID = $post_id; 
     85                $comment_post_ID = (int) $post_id; 
    8686                $num_comments = 0; 
    8787                foreach ($comments as $comment) { 
  • branches/2.1/wp-admin/import/mt.php

    r4608 r5092  
    172172        } 
    173173        $this->file = $file['file']; 
    174         $this->id = $file['id']; 
     174        $this->id = (int) $file['id']; 
    175175 
    176176        $this->get_entries(); 
     
    296296                } 
    297297 
    298                 $comment_post_ID = $post_id; 
     298                $comment_post_ID = (int) $post_id; 
    299299                $comment_approved = 1; 
    300300 
  • branches/2.1/wp-admin/import/wordpress.php

    r4742 r5092  
    175175        } 
    176176        $this->file = $file['file']; 
    177         $this->id = $file['id']; 
     177        $this->id = (int) $file['id']; 
    178178 
    179179        $this->get_entries(); 
     
    202202                $category_parent = '0'; 
    203203            else 
    204                 $category_parent = (int) category_exists($parent); 
     204                $category_parent = category_exists($parent); 
    205205 
    206206            $catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name'); 
  • branches/2.1/wp-includes/author-template.php

    r4656 r5092  
    145145function get_author_posts_url($author_id, $author_nicename = '') { 
    146146    global $wpdb, $wp_rewrite, $post, $cache_userdata; 
    147     $auth_ID = $author_id; 
     147    $auth_ID = (int) $author_id; 
    148148    $link = $wp_rewrite->get_author_permastruct(); 
    149149 
  • branches/2.1/wp-includes/bookmark-template.php

    r5057 r5092  
    166166        return ''; 
    167167 
    168     $cat_id = $cats[0]; // Take the first cat. 
     168    $cat_id = (int) $cats[0]; // Take the first cat. 
    169169 
    170170    $cat = get_category($cat_id); 
  • branches/2.1/wp-includes/category-template.php

    r5083 r5092  
    6565    $id = (int) $id; 
    6666    if ( !$id ) 
    67         $id = $post->ID; 
     67        $id = (int) $post->ID; 
    6868 
    6969    if ( !isset($category_cache[$blog_id][$id]) ) 
  • branches/2.1/wp-includes/comment-template.php

    r5040 r5092  
    151151 
    152152    if ( !$post_id ) 
    153         $post_id = $id; 
     153        $post_id = (int) $id; 
    154154 
    155155    $post = get_post($post_id); 
  • branches/2.1/wp-includes/comment.php

    r5057 r5092  
    346346    "); 
    347347 
    348     $id = $wpdb->insert_id; 
     348    $id = (int) $wpdb->insert_id; 
    349349 
    350350    if ( $comment_approved == 1) 
  • branches/2.1/wp-includes/feed.php

    r4626 r5092  
    109109 
    110110function get_author_rss_link($echo = false, $author_id, $author_nicename) { 
    111     $auth_ID = $author_id; 
     111    $auth_ID = (int) $author_id; 
    112112    $permalink_structure = get_option('permalink_structure'); 
    113113 
  • branches/2.1/wp-includes/functions.php

    r5057 r5092  
    567567    $count = count( $post_id_array); 
    568568    for ( $i = 0; $i < $count; $i++ ) { 
    569         $post_id = $post_id_array[ $i ]; 
     569        $post_id = (int) $post_id_array[ $i ]; 
    570570        if ( isset( $category_cache[$blog_id][$post_id] ) ) { 
    571571            unset( $post_id_array[ $i ] ); 
     
    621621    $count = count( $post_id_array); 
    622622    for ( $i = 0; $i < $count; $i++ ) { 
    623         $post_id = $post_id_array[ $i ]; 
     623        $post_id = (int) $post_id_array[ $i ]; 
    624624        if ( isset( $post_meta_cache[$blog_id][$post_id] ) ) { // If the meta is already cached 
    625625            unset( $post_id_array[ $i ] ); 
  • branches/2.1/wp-includes/link-template.php

    r5079 r5092  
    9696    $id = (int) $id; 
    9797    if ( !$id ) 
    98         $id = $post->ID; 
     98        $id = (int) $post->ID; 
    9999 
    100100    if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) 
     
    111111 
    112112    if ( !$id ) 
    113         $id = $post->ID; 
     113        $id = (int) $post->ID; 
    114114 
    115115    $pagestruct = $wp_rewrite->get_page_permastruct(); 
     
    132132 
    133133    if (! $id) { 
    134         $id = $post->ID; 
     134        $id = (int) $post->ID; 
    135135    } 
    136136 
  • branches/2.1/wp-includes/pluggable.php

    r4516 r5092  
    474474function wp_verify_nonce($nonce, $action = -1) { 
    475475    $user = wp_get_current_user(); 
    476     $uid = $user->id; 
     476    $uid = (int) $user->id; 
    477477 
    478478    $i = ceil(time() / 43200); 
     
    488488function wp_create_nonce($action = -1) { 
    489489    $user = wp_get_current_user(); 
    490     $uid = $user->id; 
     490    $uid = (int) $user->id; 
    491491 
    492492    $i = ceil(time() / 43200); 
  • branches/2.1/wp-includes/post.php

    r5085 r5092  
    376376 
    377377    if ( !$post_id ) 
    378         $post_id = $id; 
     378        $post_id = (int) $id; 
    379379 
    380380    $post_id = (int) $post_id; 
     
    540540    // Get the post ID. 
    541541    if ( $update ) 
    542         $post_ID = $ID; 
     542        $post_ID = (int) $ID; 
    543543 
    544544    // Create a valid post name.  Drafts are allowed to have an empty 
     
    644644            VALUES 
    645645            ('$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')"); 
    646             $post_ID = $wpdb->insert_id; 
     646            $post_ID = (int) $wpdb->insert_id; 
    647647    } 
    648648 
     
    12551255    if ( !empty($ID) ) { 
    12561256        $update = true; 
    1257         $post_ID = $ID; 
     1257        $post_ID = (int) $ID; 
    12581258    } 
    12591259 
     
    13501350            VALUES 
    13511351            ('$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')"); 
    1352             $post_ID = $wpdb->insert_id; 
     1352            $post_ID = (int) $wpdb->insert_id; 
    13531353    } 
    13541354 
     
    15051505        if ( !$post =& get_post( $mime ) ) 
    15061506            return false; 
    1507         $post_id = $post->ID; 
     1507        $post_id = (int) $post->ID; 
    15081508        $mime = $post->post_mime_type; 
    15091509    } 
  • branches/2.1/wp-includes/registration.php

    r4651 r5092  
    9090        $query = apply_filters('update_user_query', $query); 
    9191        $wpdb->query( $query ); 
    92         $user_id = $ID; 
     92        $user_id = (int) $ID; 
    9393    } else { 
    9494        $query = "INSERT INTO $wpdb->users 
     
    9898        $query = apply_filters('create_user_query', $query); 
    9999        $wpdb->query( $query ); 
    100         $user_id = $wpdb->insert_id; 
     100        $user_id = (int) $wpdb->insert_id; 
    101101    } 
    102102 
  • branches/2.1/wp-includes/theme.php

    r4778 r5092  
    346346    global $wp_query; 
    347347 
    348     $id = $wp_query->post->ID; 
     348    $id = (int) $wp_query->post->ID; 
    349349    $template = get_post_meta($id, '_wp_page_template', true); 
    350350 
  • branches/2.1/wp-includes/user.php

    r5037 r5092  
    162162    $userdata = $user->data; 
    163163    $user_login = $user->user_login; 
    164     $user_level = $user->user_level; 
    165     $user_ID    = $user->ID; 
     164    $user_level = (int) $user->user_level; 
     165    $user_ID    = (int) $user->ID; 
    166166    $user_email = $user->user_email; 
    167167    $user_url   = $user->user_url; 
  • branches/2.1/wp-trackback.php

    r4676 r5092  
    8585    } 
    8686 
    87     $comment_post_ID = $tb_id; 
     87    $comment_post_ID = (int) $tb_id; 
    8888    $comment_author = $blog_name; 
    8989    $comment_author_email = ''; 
  • branches/2.1/xmlrpc.php

    r5083 r5092  
    210210        $this->escape($args); 
    211211 
    212         $post_ID    = $args[1]; 
     212        $post_ID    = (int) $args[1]; 
    213213        $user_login = $args[2]; 
    214214        $user_pass  = $args[3]; 
     
    245245        $this->escape($args); 
    246246 
    247         $blog_ID    = $args[1]; /* though we don't use it yet */ 
     247        $blog_ID    = (int) $args[1]; /* though we don't use it yet */ 
    248248        $user_login = $args[2]; 
    249249        $user_pass  = $args[3]; 
     
    293293        $this->escape($args); 
    294294 
    295       $blog_ID    = $args[1]; 
     295      $blog_ID    = (int) $args[1]; 
    296296      $user_login = $args[2]; 
    297297      $user_pass  = $args[3]; 
     
    327327        $this->escape($args); 
    328328 
    329       $blog_ID    = $args[1]; 
     329      $blog_ID    = (int) $args[1]; 
    330330      $user_login = $args[2]; 
    331331      $user_pass  = $args[3]; 
     
    364364        $this->escape($args); 
    365365 
    366       $blog_ID    = $args[1]; /* though we don't use it yet */ 
     366      $blog_ID    = (int) $args[1]; /* though we don't use it yet */ 
    367367      $user_login = $args[2]; 
    368368      $user_pass  = $args[3]; 
     
    463463        $this->escape($args); 
    464464 
    465       $post_ID     = $args[1]; 
     465      $post_ID     = (int) $args[1]; 
    466466      $user_login  = $args[2]; 
    467467      $user_pass   = $args[3]; 
     
    504504        $this->escape($args); 
    505505 
    506       $blog_ID     = $args[0]; // we will support this in the near future 
     506      $blog_ID     = (int) $args[0]; // we will support this in the near future 
    507507      $user_login  = $args[1]; 
    508508      $user_pass   = $args[2]; 
     
    688688        $this->escape($args); 
    689689 
    690       $post_ID     = $args[0]; 
     690      $post_ID     = (int) $args[0]; 
    691691      $user_login  = $args[1]; 
    692692      $user_pass   = $args[2]; 
     
    743743        $this->escape($args); 
    744744 
    745         $blog_ID     = $args[0]; 
     745        $blog_ID     = (int) $args[0]; 
    746746        $user_login  = $args[1]; 
    747747        $user_pass   = $args[2]; 
    748         $num_posts   = $args[3]; 
     748        $num_posts   = (int) $args[3]; 
    749749 
    750750        if (!$this->login_pass_ok($user_login, $user_pass)) { 
     
    809809        $this->escape($args); 
    810810 
    811         $blog_ID     = $args[0]; 
     811        $blog_ID     = (int) $args[0]; 
    812812        $user_login  = $args[1]; 
    813813        $user_pass   = $args[2]; 
     
    843843        global $wpdb; 
    844844 
    845         $blog_ID     = $wpdb->escape($args[0])
     845        $blog_ID     = (int) $args[0]
    846846        $user_login  = $wpdb->escape($args[1]); 
    847847        $user_pass   = $wpdb->escape($args[2]); 
     
    901901        $this->escape($args); 
    902902 
    903         $blog_ID     = $args[0]; 
     903        $blog_ID     = (int) $args[0]; 
    904904        $user_login  = $args[1]; 
    905905        $user_pass   = $args[2]; 
    906         $num_posts   = $args[3]; 
     906        $num_posts   = (int) $args[3]; 
    907907 
    908908        if (!$this->login_pass_ok($user_login, $user_pass)) { 
     
    946946        $this->escape($args); 
    947947 
    948         $blog_ID     = $args[0]; 
     948        $blog_ID     = (int) $args[0]; 
    949949        $user_login  = $args[1]; 
    950950        $user_pass   = $args[2]; 
     
    975975        $this->escape($args); 
    976976 
    977         $post_ID     = $args[0]; 
     977        $post_ID     = (int) $args[0]; 
    978978        $user_login  = $args[1]; 
    979979        $user_pass   = $args[2]; 
     
    10051005        $this->escape($args); 
    10061006 
    1007         $post_ID     = $args[0]; 
     1007        $post_ID     = (int) $args[0]; 
    10081008        $user_login  = $args[1]; 
    10091009        $user_pass   = $args[2]; 
     
    10881088        $this->escape($args); 
    10891089 
    1090         $post_ID     = $args[0]; 
     1090        $post_ID     = (int) $args[0]; 
    10911091        $user_login  = $args[1]; 
    10921092        $user_pass   = $args[2]; 
     
    11501150            // the path defines the post_ID (archives/p/XXXX) 
    11511151            $blah = explode('/', $match[0]); 
    1152             $post_ID = $blah[1]; 
     1152            $post_ID = (int) $blah[1]; 
    11531153            $way = 'from the path'; 
    11541154        } elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) { 
    11551155            // the querystring defines the post_ID (?p=XXXX) 
    11561156            $blah = explode('=', $match[0]); 
    1157             $post_ID = $blah[1]; 
     1157            $post_ID = (int) $blah[1]; 
    11581158            $way = 'from the querystring'; 
    11591159        } elseif (isset($urltest['fragment'])) { 
     
    11611161            if (intval($urltest['fragment'])) { 
    11621162                // ...an integer #XXXX (simpliest case) 
    1163                 $post_ID = $urltest['fragment']; 
     1163                $post_ID = (int) $urltest['fragment']; 
    11641164                $way = 'from the fragment (numeric)'; 
    11651165            } elseif (preg_match('/post-[0-9]+/',$urltest['fragment'])) {