How to output unlimited RSS Feed items

Right now, as wp-includes/feed-rss2.php is written, there are no ways of doing such thing by using a feed-page-specific hook or filter, so you have to either:

  1. Edit this file manually (which will be broken after every update)
  2. Make a page template with the same content and changing the query arguments before the loop runs (will generate different URLs, not a good choice but it works as expected)
  3. Alter query arguments if the page is a feed. (By using a general hook, like pre_get_posts)

I will explain the 3rd way:

function feed_unlimited_posts( $query ){
       if(is_feed())
            $query->set( 'posts_per_page', -1 );
       return $vars;
}
add_action( 'pre_get_posts', 'feed_unlimited_posts' ); 

Please Note: I haven’t done testing on this piece of code, if you did and it worked, please suggest an edit. Thanks.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)