diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 34d38dafd6..3923ca92ec 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -1213,18 +1213,6 @@ function bool_from_yn( $yn ) { function do_feed() { global $wp_query; - // Determine if we are looking at the main comment feed - $is_main_comments_feed = ( $wp_query->is_comment_feed() && ! $wp_query->is_singular() ); - - /* - * Check the queried object for the existence of posts if it is not a feed for an archive, - * search result, or main comments. By checking for the absense of posts we can prevent rendering the feed - * templates at invalid endpoints. e.g.) /wp-content/plugins/feed/ - */ - if ( ! $wp_query->have_posts() && ! ( $wp_query->is_archive() || $wp_query->is_search() || $is_main_comments_feed ) ) { - wp_die( __( 'ERROR: This is not a valid feed.' ), '', array( 'response' => 404 ) ); - } - $feed = get_query_var( 'feed' ); // Remove the pad, if present. diff --git a/tests/phpunit/tests/feed/rss2.php b/tests/phpunit/tests/feed/rss2.php index fab3726e6c..d48bc887f6 100644 --- a/tests/phpunit/tests/feed/rss2.php +++ b/tests/phpunit/tests/feed/rss2.php @@ -457,41 +457,4 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase { // There should only be one child element. $this->assertEquals( 1, count( $rss ) ); } - - /* - * Check to make sure we are not rendering feed templates for invalid feed endpoints. - * e.g. https://example.com/wp-content/feed/ - * - * @ticket 30210 - */ - function test_invalid_feed_endpoint() { - // An example of an invalid feed endpoint - $this->go_to( 'wp-content/feed/' ); - - // Queries performed on invalid feed endpoints should never contain posts. - $this->assertFalse( have_posts() ); - - // This is the assertion. Once the exception is thrown in do_feed, execution stops, preventing futher assertions. - $this->setExpectedException( 'WPDieException', 'ERROR: This is not a valid feed.' ); - do_feed(); - } - - /* - * Make sure the requested feed is registered before rendering the requested template. - * - * @ticket 30210 - */ - function test_nonexistent_feeds() { - global $wp_rewrite; - $badfeed = 'badfeed'; - - $this->assertNotContains( $badfeed, $wp_rewrite->feeds ); - - $this->go_to( '/?feed=' . $badfeed ); - - // This is the assertion. Once the exception is thrown in do_feed, execution stops, preventing futher assertions. - $this->setExpectedException( 'WPDieException', 'ERROR: This is not a valid feed template.' ); - do_feed(); - } - }