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/tests/phpunit/tests/feed/rss2.php

    r39615 r40085  
    458458        $this->assertEquals( 1, count( $rss ) );
    459459    }
    460 
    461     /*
    462      * Check to make sure we are not rendering feed templates for invalid feed endpoints.
    463      * e.g. https://example.com/wp-content/feed/
    464      *
    465      * @ticket 30210
    466      */
    467     function test_invalid_feed_endpoint() {
    468         // An example of an invalid feed endpoint
    469         $this->go_to( 'wp-content/feed/' );
    470 
    471         // Queries performed on invalid feed endpoints should never contain posts.
    472         $this->assertFalse( have_posts() );
    473 
    474         // This is the assertion. Once the exception is thrown in do_feed, execution stops, preventing futher assertions.
    475         $this->setExpectedException( 'WPDieException', 'ERROR: This is not a valid feed.' );
    476         do_feed();
    477     }
    478 
    479     /*
    480      * Make sure the requested feed is registered before rendering the requested template.
    481      *
    482      * @ticket 30210
    483      */
    484     function test_nonexistent_feeds() {
    485         global $wp_rewrite;
    486         $badfeed = 'badfeed';
    487 
    488         $this->assertNotContains( $badfeed, $wp_rewrite->feeds );
    489 
    490         $this->go_to( '/?feed=' . $badfeed );
    491 
    492         // This is the assertion. Once the exception is thrown in do_feed, execution stops, preventing futher assertions.
    493         $this->setExpectedException( 'WPDieException', 'ERROR: This is not a valid feed template.' );
    494         do_feed();
    495     }
    496 
    497460}
Note: See TracChangeset for help on using the changeset viewer.