Index: src/wp-includes/class-wp-query.php
===================================================================
--- src/wp-includes/class-wp-query.php	(revision 43896)
+++ src/wp-includes/class-wp-query.php	(working copy)
@@ -1806,6 +1806,14 @@
 		if ( ( isset( $q['posts_per_archive_page'] ) && $q['posts_per_archive_page'] != 0 ) && ( $this->is_archive || $this->is_search ) ) {
 			$q['posts_per_page'] = $q['posts_per_archive_page'];
 		}
+		if ( $this->is_feed ) {
+			// This overrides posts_per_page.
+			if ( ! empty( $q['posts_per_rss'] ) ) {
+				$q['posts_per_page'] = $q['posts_per_rss'];
+			} else {
+				$q['posts_per_page'] = get_option( 'posts_per_rss' );
+			}
+		}
 		if ( ! isset( $q['nopaging'] ) ) {
 			if ( $q['posts_per_page'] == -1 ) {
 				$q['nopaging'] = true;
@@ -1814,15 +1822,6 @@
 			}
 		}
 
-		if ( $this->is_feed ) {
-			// This overrides posts_per_page.
-			if ( ! empty( $q['posts_per_rss'] ) ) {
-				$q['posts_per_page'] = $q['posts_per_rss'];
-			} else {
-				$q['posts_per_page'] = get_option( 'posts_per_rss' );
-			}
-			$q['nopaging'] = false;
-		}
 		$q['posts_per_page'] = (int) $q['posts_per_page'];
 		if ( $q['posts_per_page'] < -1 ) {
 			$q['posts_per_page'] = abs( $q['posts_per_page'] );
@@ -2577,6 +2576,9 @@
 				 */
 				$corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
 
+				// If -1 do not set LIMIT
+				$posts_per_rss = intval( get_option( 'posts_per_rss' ) );
+				$posts_per_rss = ( -1 !== $posts_per_rss ) ? 'LIMIT ' . $posts_per_rss : '';
 				/**
 				 * Filters the LIMIT clause of the comments feed query before sending.
 				 *
@@ -2585,7 +2587,7 @@
 				 * @param string   $climits The JOIN clause of the query.
 				 * @param WP_Query $this    The WP_Query instance (passed by reference).
 				 */
-				$climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
+				$climits = apply_filters_ref_array( 'comment_feed_limits', array( $posts_per_rss , &$this ) );
 			}
 			$cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : '';
 			$corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
@@ -2991,8 +2993,11 @@
 			$corderby = apply_filters_ref_array( 'comment_feed_orderby', array( 'comment_date_gmt DESC', &$this ) );
 			$corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : '';
 
+			// If -1 do not set LIMIT
+			$posts_per_rss = intval( get_option( 'posts_per_rss' ) );
+			$posts_per_rss = ( -1 !== $posts_per_rss ) ? 'LIMIT ' . $posts_per_rss : '';
 			/** This filter is documented in wp-includes/query.php */
-			$climits = apply_filters_ref_array( 'comment_feed_limits', array( 'LIMIT ' . get_option( 'posts_per_rss' ), &$this ) );
+			$climits = apply_filters_ref_array( 'comment_feed_limits', array( $posts_per_rss,  &$this ) );
 
 			$comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits";
 			$comments         = $wpdb->get_results( $comments_request );
Index: tests/phpunit/tests/query.php
===================================================================
--- tests/phpunit/tests/query.php	(revision 43896)
+++ tests/phpunit/tests/query.php	(working copy)
@@ -57,6 +57,43 @@
 	}
 
 	/**
+	 * @ticket 42261
+	 */
+	function test_rss_post_query_no_limit() {
+		self::factory()->post->create_many( 15 );
+
+		// Programmatically set posts_per_rss to -1
+		add_filter( 'option_posts_per_rss', array( $this, 'filter_option_posts_per_rss' ) );
+
+		$this->go_to( get_feed_link() );
+
+		global $wp_query;
+
+		$this->assertEquals( 15, count( $wp_query->posts ) );
+	}
+
+	/**
+	 * @ticket 42261
+	 */
+	function test_rss_comment_query_no_limit() {
+		$post_id = self::factory()->post->create();
+		self::factory()->comment->create_post_comments( $post_id, 30 );
+
+		// Programmatically set posts_per_rss to -1
+		add_filter( 'option_posts_per_rss', array( $this, 'filter_option_posts_per_rss' ) );
+
+		$this->go_to( home_url( '/comments/feed/' ) );
+
+		global $wp_query;
+
+		$this->assertEquals( 30, count( $wp_query->comments ) );
+	}
+
+	public function filter_option_posts_per_rss() {
+		return -1;
+	}
+
+	/**
 	 * @ticket 26627
 	 */
 	function test_tag_queried_object() {
