Ticket #4575: 4575.12.diff
File 4575.12.diff, 5.3 KB (added by , 7 years ago) |
---|
-
src/wp-includes/feed-atom-comments.php
45 45 46 46 <updated> 47 47 <?php 48 $date = get_last commentmodified( 'GMT');48 $date = get_last_build_date(); 49 49 echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date, false ) : date( 'Y-m-d\TH:i:s\Z' ); 50 50 ?> 51 51 </updated> -
src/wp-includes/feed-atom.php
32 32 33 33 <updated> 34 34 <?php 35 $date = get_last postmodified( 'GMT');35 $date = get_last_build_date(); 36 36 echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date, false ) : date( 'Y-m-d\TH:i:s\Z' ); 37 37 ?> 38 38 </updated> -
src/wp-includes/feed-rss2-comments.php
51 51 <description><?php bloginfo_rss( 'description' ); ?></description> 52 52 <lastBuildDate> 53 53 <?php 54 $date = get_last commentmodified( 'GMT' );54 $date = get_last_build_date(); 55 55 echo $date ? mysql2date( 'r', $date, false ) : date( 'r' ); 56 56 ?> 57 57 </lastBuildDate> -
src/wp-includes/feed-rss2.php
44 44 <description><?php bloginfo_rss( 'description' ); ?></description> 45 45 <lastBuildDate> 46 46 <?php 47 $date = get_last postmodified( 'GMT');47 $date = get_last_build_date(); 48 48 echo $date ? mysql2date( 'r', $date, false ) : date( 'r' ); 49 49 ?> 50 50 </lastBuildDate> -
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 * @global WP_Query $wp_query 98 * 99 * @since 5.0.0 100 * 101 * @return string The timestamp. 102 */ 103 function get_last_build_date() { 104 global $wp_query; 105 106 if ( ! $wp_query->have_posts() ) { 107 // Fallback to last time any post was modified or published. 108 return get_lastpostmodified( 'GMT' ); 109 } 110 111 // Extract the post modified times from the posts. 112 $modified_times = wp_list_pluck( $wp_query->posts, 'post_modified_gmt' ); 113 114 // If this is a comment feed, check those objects too. 115 if ( $wp_query->is_comment_feed() && $wp_query->comment_count ) { 116 // Extract the comment modified times from the comments. 117 $comment_times = wp_list_pluck( $wp_query->comments, 'comment_date_gmt' ); 118 119 // Add the comment times to the post times for comparison. 120 $modified_times = array_merge( $modified_times, $comment_times ); 121 } 122 123 // Determine the maximum modified time. 124 $max_modified_time = max( $modified_times ); 125 126 /** 127 * Filters the date the last post or comment in the query was modified. 128 * 129 * @since 4.9.0 130 * 131 * @param string $max_modified_times Date the last post or comment was modified in the query. 132 */ 133 return apply_filters( 'get_last_build_date', $max_modified_time ); 134 } 135 136 /** 92 137 * Retrieve the blog title for the feed title. 93 138 * 94 139 * @since 2.2.0 -
tests/phpunit/tests/feed/rss2.php
36 36 ); 37 37 38 38 // Set a predictable time for testing date archives. 39 self::$post_date = '2003-05-27 10:07:53';39 self::$post_date = strtotime( '2003-05-27 10:07:53' ); 40 40 41 41 $count = get_option( 'posts_per_rss' ) + 1; 42 42 43 43 // Create a few posts 44 self::$posts = $factory->post->create_many( 45 $count, array( 44 self::$posts = array(); 45 for ( $i = 1; $i <= $count; $i ++ ) { 46 self::$posts[] = $factory->post->create( array( 46 47 'post_author' => self::$user_id, 47 'post_date' => self::$post_date, 48 'post_date' => gmdate( 'Y-m-d H:i:s', self::$post_date + ( 5 * $i ) ), 49 // Separate post dates 5 seconds apart. 48 50 '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.', 49 51 'post_excerpt' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 50 ) 51 );52 ) ); 53 } 52 54 53 55 // Assign a category to those posts 54 56 foreach ( self::$posts as $post ) { … … 89 91 } 90 92 91 93 /** 94 * Test <rss> element has correct last build date. 95 * 96 * @ticket 4575 97 */ 98 function test_get_last_build_date() { 99 $this->go_to( '/?feed=rss2' ); 100 $feed = $this->do_rss2(); 101 $xml = xml_to_array( $feed ); 102 103 // Get the <rss> child element of <xml>. 104 $rss = xml_find( $xml, 'rss' ); 105 $last_build_date = $rss[0]['child'][0]['child'][4]['content']; 106 $this->assertEquals( strtotime( get_last_build_date() ), strtotime( $last_build_date ) ); 107 } 108 109 /** 92 110 * Test the <rss> element to make sure its present and populated 93 111 * with the expected child elements and attributes. 94 112 */