Make WordPress Core

Ticket #4575: 4575_6.diff

File 4575_6.diff, 4.8 KB (added by stevenkword, 9 years ago)
  • src/wp-includes/feed-atom-comments.php

     
    3737        ?></title>
    3838        <subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
    3939
    40         <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastcommentmodified('GMT'), false); ?></updated>
     40        <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_last_build_date(), false); ?></updated>
    4141
    4242<?php if ( is_singular() ) { ?>
    4343        <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php comments_link_feed(); ?>" />
  • src/wp-includes/feed-atom.php

     
    3030        <title type="text"><?php bloginfo_rss('name'); wp_title_rss(); ?></title>
    3131        <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle>
    3232
    33         <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></updated>
     33        <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_last_build_date(), false); ?></updated>
    3434
    3535        <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php bloginfo_rss('url') ?>" />
    3636        <id><?php bloginfo('atom_url'); ?></id>
  • src/wp-includes/feed-rss2-comments.php

     
    4343        <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    4444        <link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
    4545        <description><?php bloginfo_rss("description") ?></description>
    46         <lastBuildDate><?php echo mysql2date('r', get_last_build_date_feed(), false ); ?></lastBuildDate>
     46        <lastBuildDate><?php echo mysql2date('r', get_last_build_date(), false ); ?></lastBuildDate>
    4747        <sy:updatePeriod><?php
    4848                /** This filter is documented in wp-includes/feed-rss2.php */
    4949                echo apply_filters( 'rss_update_period', 'hourly' );
  • src/wp-includes/feed-rss2.php

     
    4242        <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    4343        <link><?php bloginfo_rss('url') ?></link>
    4444        <description><?php bloginfo_rss("description") ?></description>
    45         <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_last_build_date_feed(), false); ?></lastBuildDate>
     45        <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_last_build_date(), false); ?></lastBuildDate>
    4646        <language><?php bloginfo_rss( 'language' ); ?></language>
    4747        <sy:updatePeriod><?php
    4848                $duration = 'hourly';
  • src/wp-includes/feed.php

     
    9797 *
    9898 * @return string Date ('Y-m-d H:i:s' for use with mysql2date() )
    9999 */
    100 function get_last_build_date_feed() {
    101         global $wp_query, $wpdb;
     100function get_last_build_date() {
     101        global $wp_query;
    102102
    103103        if ( $wp_query->have_posts() ) {
    104                 $post_ids = array();
    105                 $post_times = array();
    106                 foreach( $wp_query->posts as $post ) {
    107                         $post_ids[] = $post->ID;
    108                         $post_times[] = $post->post_modified_gmt;
    109                 }
    110                 $postids = implode( "','", $post_ids );
     104                // Determine max post time
     105                $post_ids = wp_list_pluck( $wp_query->posts, 'ID' );
     106                $post_times = wp_list_pluck( $wp_query->posts, 'post_modified_gmt' );
    111107                $max_post_time = max( $post_times );
    112108
    113                 if ( $wp_query->is_comment_feed() ) {
    114                         $max_comment_time = $wpdb->get_var( $wpdb->prepare( "SELECT MAX(comment_date_gmt) FROM $wpdb->comments WHERE comment_post_ID IN ('%s') AND comment_approved = '1'", $postids ) );
     109                // If this is a comment feed, we want to check those objects too
     110                if( $wp_query->is_comment_feed() && $wp_query->have_comments() ) {
     111                        $comments_query = new WP_Comment_Query;
     112                        $comments = $comments_query->query( array(
     113                                'post__in' => $post_ids
     114                         ) );
    115115
     116                        // Determine max comment time
     117                        $comment_times = wp_list_pluck( $comments, 'comment_date_gmt' );
     118                        $max_comment_time = max( $comment_times );
     119
     120                        // Return the most recent timestamp between posts and comments
    116121                        return max( $max_post_time, $max_comment_time );
    117122                }
     123                // Return the most recent post timestamp if there are no comments to consider
    118124                return $max_post_time;
    119125        }
    120126
    121         // Fallback to last time any post was modified or published.
     127        // Fallback to last time any post was modified or published
    122128        return get_lastpostmodified( 'GMT' );
    123129}
    124130