WordPress.org

Make WordPress Core

Ticket #9642: 9642-posts.diff

File 9642-posts.diff, 6.8 KB (added by Denis-de-Bernardy, 9 years ago)

this is not finished yet

  • wp-includes/post.php

     
    12761276                $limit = "LIMIT $num";
    12771277        }
    12781278
    1279         $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC $limit";
     1279        $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date_gmt DESC $limit";
    12801280        $result = $wpdb->get_results($sql,ARRAY_A);
    12811281
    12821282        return $result ? $result : array();
  • wp-includes/version.php

     
    1515 *
    1616 * @global int $wp_db_version
    1717 */
    18 $wp_db_version = 10850;
     18$wp_db_version = 10880;
    1919
    2020?>
  • wp-includes/query.php

     
    20222022
    20232023                // Order by
    20242024                if ( empty($q['orderby']) ) {
    2025                         $q['orderby'] = "$wpdb->posts.post_date ".$q['order'];
     2025                        $q['orderby'] = "$wpdb->posts.post_date_gmt ".$q['order'];
    20262026                } else {
    20272027                        // Used to filter values
    20282028                        $allowed_keys = array('author', 'date', 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand');
  • wp-includes/wp-db.php

     
    714714
    715715                        // Return number of rows selected
    716716                        $return_val = $this->num_rows;
     717                       
     718                        // log explain
     719                        if ( defined('QUERIES_DEBUG') && defined('SAVEQUERIES') && QUERIES_DEBUG && SAVEQUERIES && 'SELECT FOUND_ROWS()' != $query ) {
     720                                $explain = @mysql_query("EXPLAIN $query", $this->dbh);
     721                                $this->queries[] = @mysql_fetch_object($explain);
     722                        }
    717723                }
    718724
    719725                return $return_val;
  • wp-includes/general-template.php

     
    776776        $output = '';
    777777
    778778        if ( 'monthly' == $type ) {
    779                 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit";
     779                $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY YEAR(post_date) DESC, MONTH(post_date) DESC $limit";
    780780                $key = md5($query);
    781781                $cache = wp_cache_get( 'wp_get_archives' , 'general');
    782782                if ( !isset( $cache[ $key ] ) ) {
  • wp-admin/admin-ajax.php

     
    11821182        if ( count($search_terms) > 1 && $search_terms[0] != $s )
    11831183                $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')";
    11841184
    1185         $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND $search ORDER BY post_date_gmt DESC LIMIT 50" );
     1185        $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND $search ORDER BY post_date DESC LIMIT 50" );
    11861186
    11871187        if ( ! $posts )
    11881188                exit( __('No posts found.') );
  • wp-admin/includes/upgrade.php

     
    654654
    655655        if ( $wp_current_db_version < 3506 ) {
    656656                // Update status and type.
    657                 $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
    658 
    659                 if ( ! empty($posts) ) foreach ($posts as $post) {
    660                         $status = $post->post_status;
    661                         $type = 'post';
    662 
    663                         if ( 'static' == $status ) {
    664                                 $status = 'publish';
    665                                 $type = 'page';
    666                         } else if ( 'attachment' == $status ) {
    667                                 $status = 'inherit';
    668                                 $type = 'attachment';
    669                         }
    670 
    671                         $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_status = %s, post_type = %s WHERE ID = %d", $status, $type, $post->ID) );
    672                 }
     657                $wpdb->query("
     658                        UPDATE  $wpdb->posts
     659                        SET             post_type = CASE
     660                                        WHEN post_status = 'page'
     661                                        THEN 'page'
     662                                        WHEN post_status = 'attachment'
     663                                        THEN 'attachment'
     664                                        ELSE 'post'
     665                                        END,
     666                                        post_status = CASE
     667                                        WHEN post_status = 'page'
     668                                        THEN 'publish'
     669                                        WHEN post_status = 'attachment'
     670                                        THEN 'inherit'
     671                                        ELSE post_status
     672                                        END;
     673                        ");
    673674        }
    674675
    675676        if ( $wp_current_db_version < 3845 ) {
  • wp-admin/includes/schema.php

     
    136136  post_mime_type varchar(100) NOT NULL default '',
    137137  comment_count bigint(20) NOT NULL default '0',
    138138  PRIMARY KEY  (ID),
     139  KEY post_author (post_author),
    139140  KEY post_name (post_name),
    140   KEY type_status_date (post_type,post_status,post_date,ID),
    141   KEY post_parent (post_parent)
     141  KEY type_date (post_type, post_date),
     142  KEY type_parent (post_type, post_parent),
     143  KEY type_date_gmt (post_type, post_date_gmt),
     144  KEY type_modified_gmt (post_type, post_modified_gmt)
    142145) $charset_collate;
    143146CREATE TABLE $wpdb->users (
    144147  ID bigint(20) unsigned NOT NULL auto_increment,
  • wp-admin/includes/user.php

     
    324324                $other_unpubs = '';
    325325        } else {
    326326                $editable = join(',', $editable);
    327                 $other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
     327                $other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified_gmt $dir", $user_id) );
    328328        }
    329329
    330330        return apply_filters('get_others_drafts', $other_unpubs);
     
    389389 */
    390390function get_users_drafts( $user_id ) {
    391391        global $wpdb;
    392         $query = $wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified DESC", $user_id);
     392        $query = $wpdb->prepare("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = %d ORDER BY post_modified_gmt DESC", $user_id);
    393393        $query = apply_filters('get_users_drafts', $query);
    394394        return $wpdb->get_results( $query );
    395395}