Make WordPress Core

Opened 13 years ago

Closed 10 years ago

Last modified 10 years ago

#17853 closed defect (bug) (fixed)

Posts_per_page=-1 overwritten in query.php if is feed, (An ics feed needs all)

Reported by: anmari's profile anmari Owned by:
Milestone: 3.9 Priority: normal
Severity: normal Version: 3.2
Component: Feeds Keywords: close has-patch
Focuses: Cc:

Description

Similar to 15852, the posts_per_page argument to wp_query, is being overwritten in lines 1991 of query.php

if ( $this->is_feed ) {
    $q['posts_per_page'] = get_option('posts_per_rss');

In the case of an ics feed - ALL requested posts must be returned for a complete feed, so need to be able to pass posts_per_page=-1 as with other queries in the front end.

This is in wp 3.2 RC1 and earlier.

As far as I can make out, the only way around for now is to add a post_limits filter and remove the LIMIT in the query when it is a ics feed. (ie return empty string)

While the workaround works, it would make more sense of the post_per_page argument worked as in front end queries.

Possible workaround (use in custom feed function only)

...
	add_filter('post_limits', 'amr_remove_limits');
...
function amr_remove_limits () {
    return ('');   
// return an empty string so that NO limits are imposed in the query
}

Attachments (1)

posts_per_rss_patch.diff (1.0 KB) - added by ssmathias 12 years ago.
ssmathias posts_per_rss patch file

Download all attachments as: .zip

Change History (12)

#1 @xknown
13 years ago

You can also attach to the filter pre_option_posts_per_rss and return -1 as you want.

#2 @solarissmoke
13 years ago

  • Keywords close added

xknown's solution works.

#3 @nacin
13 years ago

I am not entirely a fan of how this works. An override should be allowable without hooking in again. I suggest it also checks whether $q['posts_per_page'] is not set before pulling from posts_per_rss.

@ssmathias
12 years ago

ssmathias posts_per_rss patch file

#4 @ssmathias
12 years ago

I've attached a proposed fix for this issue that would allow posts_per_page overrides on the query to function normally with feeds as with any other query.

#5 @ssmathias
12 years ago

  • Cc steve@… added

#6 @ssmathias
12 years ago

  • Keywords has-patch added

#7 @tollmanz
12 years ago

  • Cc zack@… added

#8 @stephenh1988
12 years ago

  • Cc contact@… added

#9 @stephenh1988
12 years ago

Would be great to see this patch implemented.

Note @xknown's workaround will not work. At the same $q['posts_per_page'] is over-ridden by the RSS option, it sets the $['nopaging'] to false. The upshot is that the LIMIT part of the query is still included, but with a '-1' - causing an error.

Last edited 12 years ago by stephenh1988 (previous) (diff)

#10 @wonderboymusic
10 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [27456] - allows you to use posts_per_rss in feed requests to override

#11 @wonderboymusic
10 years ago

  • Milestone changed from Awaiting Review to 3.9
Note: See TracTickets for help on using tickets.