WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/20/2017 06:37:22 AM (2 years ago)
Author:
dd32
Message:

Feeds: Prevent empty feeds from returning 404 errors.

Partial revert of [38929].

This reverts the source code from the commit for #30210 to prevent valid but empty feeds from returning 404 file not found errors for the home and custom feeds.

The tests in the commit that remain applicable are retained.

Props pavelevap for reporting, stevenkword for initial patch, peterwilsoncc.
See #30210.
Merges [40030] to the 4.7 branch.
Fixes #39157.

Location:
branches/4.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.7

  • branches/4.7/src/wp-includes/functions.php

    r40075 r40085  
    12131213function do_feed() {
    12141214    global $wp_query;
    1215 
    1216     // Determine if we are looking at the main comment feed
    1217     $is_main_comments_feed = ( $wp_query->is_comment_feed() && ! $wp_query->is_singular() );
    1218 
    1219     /*
    1220      * Check the queried object for the existence of posts if it is not a feed for an archive,
    1221      * search result, or main comments. By checking for the absense of posts we can prevent rendering the feed
    1222      * templates at invalid endpoints. e.g.) /wp-content/plugins/feed/
    1223      */
    1224     if ( ! $wp_query->have_posts() && ! ( $wp_query->is_archive() || $wp_query->is_search() || $is_main_comments_feed ) ) {
    1225         wp_die( __( 'ERROR: This is not a valid feed.' ), '', array( 'response' => 404 ) );
    1226     }
    12271215
    12281216    $feed = get_query_var( 'feed' );
Note: See TracChangeset for help on using the changeset viewer.