Make WordPress Core


Ignore:
Timestamp:
10/25/2016 08:47:06 PM (9 years ago)
Author:
rachelbaker
Message:

Feeds: Always return a valid timestamp for the Last-Modified header of comment or post feeds.

Fixes bug where an invalid Last-Modified value would be returned in feed requests for sites that had 0 items to return. Comment or post feeds will now return the current timestamp as the Last-Modified header value. Example: a request for the comments feed for a site without any comments.

Replaced use of the local static variable $cache_lastcommentmodified to store the modified date in get_lastcommentmodified() with the Object Cache API. The get_lastcommentmodified() function returns early if there is a cached value and returns false if there where no comments found. Introduced _clear_modified_cache_on_transition_comment_status() to flush the lastcommentmodified cache key when a comment enters or leaves approval status. In get_lastpostmodified() return early if there is a cached value and return false if there are no posts found.

Props swissspidy, rachelbaker, dllh, leobaiano.
Fixes #38027.

File:
1 edited

Legend:

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

    r35294 r38925  
    1515    <link><?php bloginfo_rss('url') ?></link>
    1616    <description><?php bloginfo_rss('description') ?></description>
    17     <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate>
     17    <lastBuildDate><?php
     18        $date = get_lastpostmodified( 'GMT' );
     19        echo $date ? mysql2date( 'D, d M Y H:i:s +0000', $date ) : date( 'D, d M Y H:i:s +0000' );
     20    ?></lastBuildDate>
    1821    <docs>http://backend.userland.com/rss092</docs>
    1922    <language><?php bloginfo_rss( 'language' ); ?></language>
Note: See TracChangeset for help on using the changeset viewer.