Make WordPress Core

Ticket #3154: patch.diff

File patch.diff, 1.9 KB (added by alexkingorg, 20 years ago)

patch

  • query.php

     
    329329        function parse_query_vars() {
    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                );
    332362
     363                foreach ($keys as $key) {
     364                        if ( !isset($array[$key]))
     365                                $array[$key] = '';
     366                }
     367               
     368                return $array;
     369        }
     370
    333371        // Parse a query string and set query type booleans.
    334372        function parse_query ($query) {
    335373                if ( !empty($query) || !isset($this->query) ) {
     
    341379                        $this->query = $query;
    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;
    347387                        return;
     
    530570
    531571                // Shorthand.
    532572                $q = &$this->query_vars;
     573               
     574                $q = $this->fill_query_vars($q);
    533575
    534576                // First let's clear some variables
    535577                $distinct = '';
     
    540582                $where = '';
    541583                $limits = '';
    542584                $join = '';
     585                $search = '';
    543586
    544587                if ( !isset($q['post_type']) )
    545588                        $q['post_type'] = 'post';
     
    909952                        }
    910953
    911954                        if (($q['what_to_show'] == 'posts')) {
    912                                 $q['offset'] = abs(intval($q['offset']));
    913955                                if ( empty($q['offset']) ) {
    914956                                        $pgstrt = '';
    915957                                        $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
    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'];
    920963                                }