Make WordPress Core

Ticket #2604: type_status_date_key.diff

File type_status_date_key.diff, 4.7 KB (added by ryan, 20 years ago)

Add (post_type, post_status, post_date) key and shorten post_type

  • wp-includes/query.php

     
    505505                $result = '';
    506506                $where = '';
    507507                $limits = '';
    508                 $distinct = '';
    509508                $join = '';
    510509
    511510                if ( !isset($q['post_type']) )
     
    822821                                $q['orderby'] = 'post_date '.$q['order'];
    823822                }
    824823
    825                 //$now = gmdate('Y-m-d H:i:59');
    826                
    827                 //only select past-dated posts, except if a logged in user is viewing a single: then, if they
    828                 //can edit the post, we let them through
    829                 //if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) {
    830                 //      $where .= " AND post_date_gmt <= '$now'";
    831                 //      $distinct = 'DISTINCT';
    832                 //}
    833 
    834824                if ( $this->is_attachment ) {
    835825                        $where .= ' AND (post_type = "attachment")';
    836826                } elseif ($this->is_page) {
     
    842832
    843833                        if ( is_admin() )
    844834                                $where .= " OR post_status = 'future' OR post_status = 'draft'";
    845                         else
    846                                 $distinct = 'DISTINCT';
    847835       
    848836                        if ( is_user_logged_in() )
    849837                                $where .= " OR post_author = $user_ID AND post_status = 'private'))";
     
    884872                // Apply post-paging filters on where and join.  Only plugins that
    885873                // manipulate paging queries should use these hooks.
    886874                $where = apply_filters('posts_where_paged', $where);
    887                 $groupby = " $wpdb->posts.ID ";
     875                $groupby = '';
    888876                $groupby = apply_filters('posts_groupby', $groupby);
     877                if ( ! empty($groupby) )
     878                        $groupby = 'GROUP BY ' . $groupby;
    889879                $join = apply_filters('posts_join_paged', $join);
    890880                $orderby = apply_filters('posts_orderby', $q['orderby']);
    891                 $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1" . $where . " GROUP BY " . $groupby . " ORDER BY " . $orderby . " $limits";
     881                $request = " SELECT * FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits";
    892882                $this->request = apply_filters('posts_request', $request);
    893883
    894884                $this->posts = $wpdb->get_results($this->request);
  • wp-includes/version.php

     
    33// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
    44
    55$wp_version = '2.1-alpha1';
    6 $wp_db_version = 3582;
     6$wp_db_version = 3672;
    77
    88?>
     9 No newline at end of file
  • wp-includes/template-functions-links.php

     
    470470        if (isset($max_num_pages)) return $max_num_pages;
    471471       
    472472        if ( 'posts' == get_query_var('what_to_show') ) {
    473                 preg_match('#FROM\s(.*)\sGROUP BY#siU', $wp_query->request, $matches);
     473                preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
    474474                $fromwhere = $matches[1];
    475475                $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT ID) FROM $fromwhere");
    476476                return ceil($numposts / get_option('posts_per_page'));
    477477        } else {
    478478                $posts = $wp_query->posts;
    479                 preg_match('#WHERE\s(.*)\sGROUP BY#siU', $wp_query->request, $matches);
     479                preg_match('#WHERE\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
    480480                $where = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
    481481                $num_days = $wpdb->query("SELECT DISTINCT post_date FROM $wpdb->posts WHERE $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
    482482                return ceil($num_days / get_option('posts_per_page'));
  • wp-admin/upgrade-functions.php

     
    166166        if ( $wp_current_db_version < 3308 )
    167167                upgrade_160();
    168168
    169         if ( $wp_current_db_version < 3582 )
     169        if ( $wp_current_db_version < 3672 )
    170170                upgrade_210();
    171171
    172172        $wp_rewrite->flush_rules();
  • wp-admin/upgrade-schema.php

     
    113113  post_parent bigint(20) NOT NULL default '0',
    114114  guid varchar(255) NOT NULL default '',
    115115  menu_order int(11) NOT NULL default '0',
    116   post_type varchar(100) NOT NULL default 'post',
     116  post_type varchar(20) NOT NULL default 'post',
    117117  post_mime_type varchar(100) NOT NULL default '',
    118118  comment_count bigint(20) NOT NULL default '0',
    119119  PRIMARY KEY  (ID),
    120   KEY post_name (post_name)
     120  KEY post_name (post_name),
     121  KEY type_status_date (post_type, post_status, post_date)
    121122);
    122123CREATE TABLE $wpdb->users (
    123124  ID bigint(20) unsigned NOT NULL auto_increment,