Make WordPress Core

Changeset 4205


Ignore:
Timestamp:
09/21/2006 09:05:38 PM (20 years ago)
Author:
ryan
Message:

Make sure query vars are set before use. Props Alex King. fixes #3154

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r4186 r4205  
    330330                $this->parse_query('');
    331331        }
     332       
     333        function fill_query_vars($array) {
     334                $keys = array(
     335                        'error'
     336                        , 'm'
     337                        , 'p'
     338                        , 'subpost'
     339                        , 'subpost_id'
     340                        , 'attachment'
     341                        , 'attachment_id'
     342                        , 'name'
     343                        , 'hour'
     344                        , 'static'
     345                        , 'pagename'
     346                        , 'page_id'
     347                        , 'second'
     348                        , 'minute'
     349                        , 'hour'
     350                        , 'day'
     351                        , 'monthnum'
     352                        , 'year'
     353                        , 'w'
     354                        , 'category_name'
     355                        , 'author_name'
     356                        , 'feed'
     357                        , 'tb'
     358                        , 'paged'
     359                        , 'comments_popup'
     360                        , 'preview'
     361                );
     362
     363                foreach ($keys as $key) {
     364                        if ( !isset($array[$key]))
     365                                $array[$key] = '';
     366                }
     367               
     368                return $array;
     369        }
    332370
    333371        // Parse a query string and set query type booleans.
     
    342380                        $this->query_vars = $qv;
    343381                }
    344 
     382               
     383                $qv = $this->fill_query_vars($qv);
     384               
    345385                if ( ! empty($qv['robots']) ) {
    346386                        $this->is_robots = true;
     
    531571                // Shorthand.
    532572                $q = &$this->query_vars;
     573               
     574                $q = $this->fill_query_vars($q);
    533575
    534576                // First let's clear some variables
     
    541583                $limits = '';
    542584                $join = '';
     585                $search = '';
    543586
    544587                if ( !isset($q['post_type']) )
     
    910953
    911954                        if (($q['what_to_show'] == 'posts')) {
    912                                 $q['offset'] = abs(intval($q['offset']));
    913955                                if ( empty($q['offset']) ) {
    914956                                        $pgstrt = '';
     
    916958                                        $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
    917959                                } else { // we're ignoring $page and using 'offset'
     960                                        $q['offset'] = abs(intval($q['offset']));
    918961                                        $pgstrt = $q['offset'] . ', ';
    919962                                        $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
Note: See TracChangeset for help on using the changeset viewer.