Changeset 7906 for trunk/wp-includes/query.php
- Timestamp:
- 05/08/2008 05:17:27 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/query.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r7905 r7906 516 516 $this->is_robots = true; 517 517 518 $qv['p'] = (int) $qv['p'];519 $qv['page_id'] = (int) $qv['page_id'];520 $qv['year'] = (int) $qv['year'];521 $qv['monthnum'] = (int) $qv['monthnum'];522 $qv['day'] = (int) $qv['day'];523 $qv['w'] = (int) $qv['w'];524 $qv['m'] = (int) $qv['m'];518 $qv['p'] = absint($qv['p']); 519 $qv['page_id'] = absint($qv['page_id']); 520 $qv['year'] = absint($qv['year']); 521 $qv['monthnum'] = absint($qv['monthnum']); 522 $qv['day'] = absint($qv['day']); 523 $qv['w'] = absint($qv['w']); 524 $qv['m'] = absint($qv['m']); 525 525 $qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers 526 if ( '' !== $qv['hour'] ) $qv['hour'] = (int) $qv['hour'];527 if ( '' !== $qv['minute'] ) $qv['minute'] = (int) $qv['minute'];528 if ( '' !== $qv['second'] ) $qv['second'] = (int) $qv['second'];526 if ( '' !== $qv['hour'] ) $qv['hour'] = absint($qv['hour']); 527 if ( '' !== $qv['minute'] ) $qv['minute'] = absint($qv['minute']); 528 if ( '' !== $qv['second'] ) $qv['second'] = absint($qv['second']); 529 529 530 530 // Compat. Map subpost to attachment. … … 534 534 $qv['attachment_id'] = $qv['subpost_id']; 535 535 536 $qv['attachment_id'] = (int) $qv['attachment_id'];536 $qv['attachment_id'] = absint($qv['attachment_id']); 537 537 538 538 if ( ('' != $qv['attachment']) || !empty($qv['attachment_id']) ) { … … 625 625 $qv['category__in'] = array(); 626 626 } else { 627 $qv['category__in'] = array_map(' intval', $qv['category__in']);627 $qv['category__in'] = array_map('absint', $qv['category__in']); 628 628 $this->is_category = true; 629 629 } … … 632 632 $qv['category__not_in'] = array(); 633 633 } else { 634 $qv['category__not_in'] = array_map(' intval', $qv['category__not_in']);634 $qv['category__not_in'] = array_map('absint', $qv['category__not_in']); 635 635 } 636 636 … … 638 638 $qv['category__and'] = array(); 639 639 } else { 640 $qv['category__and'] = array_map(' intval', $qv['category__and']);640 $qv['category__and'] = array_map('absint', $qv['category__and']); 641 641 $this->is_category = true; 642 642 } … … 645 645 $this->is_tag = true; 646 646 647 $qv['tag_id'] = (int) $qv['tag_id'];647 $qv['tag_id'] = absint($qv['tag_id']); 648 648 if ( !empty($qv['tag_id']) ) 649 649 $this->is_tag = true; … … 652 652 $qv['tag__in'] = array(); 653 653 } else { 654 $qv['tag__in'] = array_map(' intval', $qv['tag__in']);654 $qv['tag__in'] = array_map('absint', $qv['tag__in']); 655 655 $this->is_tag = true; 656 656 } … … 659 659 $qv['tag__not_in'] = array(); 660 660 } else { 661 $qv['tag__not_in'] = array_map(' intval', $qv['tag__not_in']);661 $qv['tag__not_in'] = array_map('absint', $qv['tag__not_in']); 662 662 } 663 663 … … 665 665 $qv['tag__and'] = array(); 666 666 } else { 667 $qv['tag__and'] = array_map(' intval', $qv['tag__and']);667 $qv['tag__and'] = array_map('absint', $qv['tag__and']); 668 668 $this->is_category = true; 669 669 } … … 872 872 if (isset($q['page'])) { 873 873 $q['page'] = trim($q['page'], '/'); 874 $q['page'] = (int) $q['page']; 875 $q['page'] = abs($q['page']); 874 $q['page'] = absint($q['page']); 876 875 } 877 876 … … 950 949 951 950 if ( intval($q['comments_popup']) ) 952 $q['p'] = intval($q['comments_popup']);951 $q['p'] = absint($q['comments_popup']); 953 952 954 953 // If an attachment is requested by number, let it supercede any post number. 955 954 if ( $q['attachment_id'] ) 956 $q['p'] = $q['attachment_id'];955 $q['p'] = absint($q['attachment_id']); 957 956 958 957 // If a post number is specified, load that post 959 if ( $q['p'] ) 960 $where = " AND {$wpdb->posts}.ID = " . $q['p']; 961 elseif ( $q['post_parent'] ) 962 $where = $wpdb->prepare("AND $wpdb->posts.post_parent = %d ", $q['post_parent']); 963 elseif ( $q['post__in'] ) { 964 $post__in = "'" . implode("', '", $q['post__in']) . "'"; 965 $where = " AND {$wpdb->posts}.ID IN ($post__in)"; 958 if ( $q['p'] ) { 959 $where .= " AND {$wpdb->posts}.ID = " . $q['p']; 960 } elseif ( $q['post__in'] ) { 961 $post__in = implode(',', array_map( 'absint', $q['post__in'] )); 962 $where .= " AND {$wpdb->posts}.ID IN ($post__in)"; 966 963 } elseif ( $q['post__not_in'] ) { 967 $post__not_in = "'" . implode("', '", $q['post__not_in']) . "'"; 968 $where = " AND {$wpdb->posts}.ID NOT IN ($post__not_in)"; 969 } 964 $post__not_in = implode(',', array_map( 'absint', $q['post__not_in'] )); 965 $where .= " AND {$wpdb->posts}.ID NOT IN ($post__not_in)"; 966 } 967 968 if ( $q['post_parent'] ) 969 $where .= $wpdb->prepare( " AND $wpdb->posts.post_parent = %d ", $q['post_parent'] ); 970 970 971 971 if ( $q['page_id'] ) { … … 1208 1208 $andor = 'AND'; 1209 1209 $q['author'] = explode('-', $q['author']); 1210 $q['author'] = '' .intval($q['author'][1]);1210 $q['author'] = '' . absint($q['author'][1]); 1211 1211 } else { 1212 1212 $eq = '='; … … 1214 1214 } 1215 1215 $author_array = preg_split('/[,\s]+/', $q['author']); 1216 $whichauthor .= " AND ($wpdb->posts.post_author ".$eq.' '. intval($author_array[0]);1216 $whichauthor .= " AND ($wpdb->posts.post_author ".$eq.' '.absint($author_array[0]); 1217 1217 for ($i = 1; $i < (count($author_array)); $i = $i + 1) { 1218 $whichauthor .= ' '.$andor." $wpdb->posts.post_author ".$eq.' '. intval($author_array[$i]);1218 $whichauthor .= ' '.$andor." $wpdb->posts.post_author ".$eq.' '.absint($author_array[$i]); 1219 1219 } 1220 1220 $whichauthor .= ')'; … … 1234 1234 $q['author_name'] = sanitize_title($q['author_name']); 1235 1235 $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'"); 1236 $whichauthor .= " AND ($wpdb->posts.post_author = ". intval($q['author']).')';1236 $whichauthor .= " AND ($wpdb->posts.post_author = ".absint($q['author']).')'; 1237 1237 } 1238 1238 … … 1374 1374 if ( empty($q['offset']) ) { 1375 1375 $pgstrt = ''; 1376 $pgstrt = ( intval($page) -1) * $q['posts_per_page'] . ', ';1376 $pgstrt = ($page - 1) * $q['posts_per_page'] . ', '; 1377 1377 $limits = 'LIMIT '.$pgstrt.$q['posts_per_page']; 1378 1378 } else { // we're ignoring $page and using 'offset'
Note: See TracChangeset
for help on using the changeset viewer.