Ticket #4575: 4575.10.diff
File 4575.10.diff, 5.7 KB (added by , 7 years ago) |
---|
-
src/wp-includes/feed-atom-comments.php
42 42 <subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle> 43 43 44 44 <updated><?php 45 $date = get_last commentmodified( 'GMT');45 $date = get_last_build_date(); 46 46 echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date, false ) : date( 'Y-m-d\TH:i:s\Z' ); 47 47 ?></updated> 48 48 -
src/wp-includes/feed-atom.php
31 31 <subtitle type="text"><?php bloginfo_rss("description") ?></subtitle> 32 32 33 33 <updated><?php 34 $date = get_last postmodified( 'GMT');34 $date = get_last_build_date(); 35 35 echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date, false ) : date( 'Y-m-d\TH:i:s\Z' ); 36 36 ?></updated> 37 37 -
src/wp-includes/feed-rss2-comments.php
48 48 <link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link> 49 49 <description><?php bloginfo_rss("description") ?></description> 50 50 <lastBuildDate><?php 51 $date = get_last commentmodified( 'GMT');51 $date = get_last_build_date(); 52 52 echo $date ? mysql2date( 'r', $date, false ) : date( 'r' ); 53 53 ?></lastBuildDate> 54 54 <sy:updatePeriod><?php -
src/wp-includes/feed-rss2.php
43 43 <link><?php bloginfo_rss('url') ?></link> 44 44 <description><?php bloginfo_rss("description") ?></description> 45 45 <lastBuildDate><?php 46 $date = get_last postmodified( 'GMT');46 $date = get_last_build_date(); 47 47 echo $date ? mysql2date( 'r', $date, false ) : date( 'r' ); 48 48 ?></lastBuildDate> 49 49 <language><?php bloginfo_rss( 'language' ); ?></language> -
src/wp-includes/feed.php
89 89 } 90 90 91 91 /** 92 * Get the timestamp of the most recently modified post from WP_Query 93 * 94 * If viewing a comment feed, the date of the most recently modified 95 * comment will be returned. 96 * 97 * @since 4.8.1 98 * 99 * @return string Date ('Y-m-d H:i:s' for use with mysql2date() ) 100 */ 101 function get_last_build_date() { 102 global $wp_query; 103 104 if ( $wp_query->have_posts() ) { 105 // Determine max post time 106 $post_times = wp_list_pluck( $wp_query->posts, 'post_modified_gmt' ); 107 $max_post_time = max( $post_times ); 108 109 // If this is a comment feed, check those objects too 110 if ( $wp_query->is_comment_feed() && $wp_query->have_comments() ) { 111 // Determine the max comment time 112 $comment_times = wp_list_pluck( $wp_query->comments, 'comment_date_gmt' ); 113 $max_comment_time = max( $comment_times ); 114 115 // Return the most recent timestamp between posts and comments 116 return max( $max_post_time, $max_comment_time ); 117 } 118 // Return the most recent post timestamp if there are no comments to consider 119 return $max_post_time; 120 } 121 122 // Fallback to last time any post was modified or published 123 return get_lastpostmodified( 'GMT' ); 124 } 125 126 /** 92 127 * Retrieve the blog title for the feed title. 93 128 * 94 129 * @since 2.2.0 -
tests/phpunit/tests/feed/rss2.php
32 32 ) ); 33 33 34 34 // Set a predictable time for testing date archives. 35 self::$post_date = '2003-05-27 10:07:53';35 self::$post_date = strtotime( '2003-05-27 10:07:53' ); 36 36 37 37 $count = get_option( 'posts_per_rss' ) + 1; 38 $i = 0; 38 39 39 40 // Create a few posts 40 self::$posts = $factory->post->create_many( $count, array( 41 'post_author' => self::$user_id, 42 'post_date' => self::$post_date, 43 'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec velit massa, ultrices eu est suscipit, mattis posuere est. Donec vitae purus lacus. Cras vitae odio odio.', 44 'post_excerpt' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 45 ) ); 41 self::$posts = array(); 42 while ( $count-- ) { 43 self::$posts[] = $factory->post->create( array( 44 'post_author' => self::$user_id, 45 'post_date' => gmdate( 'Y-m-d H:i:s', self::$post_date + ( 5 * ++$i ) ), // separate post dates 5 seconds apart. 46 'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec velit massa, ultrices eu est suscipit, mattis posuere est. Donec vitae purus lacus. Cras vitae odio odio.', 47 'post_excerpt' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 48 ) ); 49 } 46 50 47 51 // Assign a category to those posts 48 52 foreach ( self::$posts as $post ) { … … 83 87 } 84 88 85 89 /** 90 * Test <rss> element has correct last build date. 91 */ 92 function test_get_last_build_date() { 93 $this->go_to( '/?feed=rss2' ); 94 $feed = $this->do_rss2(); 95 $xml = xml_to_array( $feed ); 96 97 // Get the <rss> child element of <xml>. 98 $rss = xml_find( $xml, 'rss' ); 99 $last_build_date = $rss[0]['child'][0]['child'][4]['content']; 100 $this->assertEquals( strtotime( get_last_build_date() ), strtotime( $last_build_date ) ); 101 } 102 103 /** 86 104 * Test the <rss> element to make sure its present and populated 87 105 * with the expected child elements and attributes. 88 106 */