Make WordPress Core


Ignore:
Timestamp:
04/20/2022 12:46:01 PM (2 years ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp.php

    r52815 r53233  
    414414        $status        = null;
    415415        $exit_required = false;
     416        $date_format   = 'D, d M Y H:i:s';
    416417
    417418        if ( is_user_logged_in() ) {
     
    421422            $expires = 10 * MINUTE_IN_SECONDS;
    422423
    423             $headers['Expires']       = gmdate( 'D, d M Y H:i:s', time() + $expires );
     424            $headers['Expires']       = gmdate( $date_format, time() + $expires );
    424425            $headers['Cache-Control'] = sprintf(
    425426                'max-age=%d, must-revalidate',
     
    460461                )
    461462            ) {
    462                 $wp_last_modified = mysql2date( 'D, d M Y H:i:s', get_lastcommentmodified( 'GMT' ), false );
     463                $wp_last_modified_post    = mysql2date( $date_format, get_lastpostmodified( 'GMT' ), false );
     464                $wp_last_modified_comment = mysql2date( $date_format, get_lastcommentmodified( 'GMT' ), false );
     465                if ( strtotime( $wp_last_modified_post ) > strtotime( $wp_last_modified_comment ) ) {
     466                    $wp_last_modified = $wp_last_modified_post;
     467                } else {
     468                    $wp_last_modified = $wp_last_modified_comment;
     469                }
    463470            } else {
    464                 $wp_last_modified = mysql2date( 'D, d M Y H:i:s', get_lastpostmodified( 'GMT' ), false );
     471                $wp_last_modified = mysql2date( $date_format, get_lastpostmodified( 'GMT' ), false );
    465472            }
    466473
    467474            if ( ! $wp_last_modified ) {
    468                 $wp_last_modified = gmdate( 'D, d M Y H:i:s' );
     475                $wp_last_modified = gmdate( $date_format );
    469476            }
    470477
Note: See TracChangeset for help on using the changeset viewer.