Feeds: Use latest comment date for the `Last-Modified` header of comments feed.
Previously, the `Last-Modified` header of comments feed was using the date/time of the last comment. This behavior was breaking caching and causing feed readers to believe there is no new content even when there might be new posts. This commit changes this behavior to use the newest date from both `get_lastcommentmodified()` and `get_lastpostmodified()` functions instead of only using the result from `get_lastcommentmodified()`. Props xiven, mauteri, costdev, audrasjb. Fixes #47968. Built from https://develop.svn.wordpress.org/trunk@53233 git-svn-id: http://core.svn.wordpress.org/trunk@52822 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0cc2cb34cd
commit
943e956379
|
@ -413,6 +413,7 @@ class WP {
|
|||
$headers = array();
|
||||
$status = null;
|
||||
$exit_required = false;
|
||||
$date_format = 'D, d M Y H:i:s';
|
||||
|
||||
if ( is_user_logged_in() ) {
|
||||
$headers = array_merge( $headers, wp_get_nocache_headers() );
|
||||
|
@ -420,7 +421,7 @@ class WP {
|
|||
// Unmoderated comments are only visible for 10 minutes via the moderation hash.
|
||||
$expires = 10 * MINUTE_IN_SECONDS;
|
||||
|
||||
$headers['Expires'] = gmdate( 'D, d M Y H:i:s', time() + $expires );
|
||||
$headers['Expires'] = gmdate( $date_format, time() + $expires );
|
||||
$headers['Cache-Control'] = sprintf(
|
||||
'max-age=%d, must-revalidate',
|
||||
$expires
|
||||
|
@ -459,13 +460,19 @@ class WP {
|
|||
)
|
||||
)
|
||||
) {
|
||||
$wp_last_modified = mysql2date( 'D, d M Y H:i:s', get_lastcommentmodified( 'GMT' ), false );
|
||||
$wp_last_modified_post = mysql2date( $date_format, get_lastpostmodified( 'GMT' ), false );
|
||||
$wp_last_modified_comment = mysql2date( $date_format, get_lastcommentmodified( 'GMT' ), false );
|
||||
if ( strtotime( $wp_last_modified_post ) > strtotime( $wp_last_modified_comment ) ) {
|
||||
$wp_last_modified = $wp_last_modified_post;
|
||||
} else {
|
||||
$wp_last_modified = $wp_last_modified_comment;
|
||||
}
|
||||
} else {
|
||||
$wp_last_modified = mysql2date( 'D, d M Y H:i:s', get_lastpostmodified( 'GMT' ), false );
|
||||
$wp_last_modified = mysql2date( $date_format, get_lastpostmodified( 'GMT' ), false );
|
||||
}
|
||||
|
||||
if ( ! $wp_last_modified ) {
|
||||
$wp_last_modified = gmdate( 'D, d M Y H:i:s' );
|
||||
$wp_last_modified = gmdate( $date_format );
|
||||
}
|
||||
|
||||
$wp_last_modified .= ' GMT';
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.0-beta2-53232';
|
||||
$wp_version = '6.0-beta2-53233';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue