WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 13 months ago

Last modified 13 months 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 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 3 years ago.
ssmathias posts_per_rss patch file

Download all attachments as: .zip

Change History (12)

comment:1 @xknown4 years ago

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

comment:2 @solarissmoke3 years ago

  • Keywords close added

xknown's solution works.

comment:3 @nacin3 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.

@ssmathias3 years ago

ssmathias posts_per_rss patch file

comment:4 @ssmathias3 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.

comment:5 @ssmathias3 years ago

  • Cc steve@… added

comment:6 @ssmathias3 years ago

  • Keywords has-patch added

comment:7 @tollmanz3 years ago

  • Cc zack@… added

comment:8 @stephenh19883 years ago

  • Cc contact@… added

comment:9 @stephenh19883 years ago

Would be great to see this patch implemented.

Note @xknown's workaround will not work. At the same $qposts_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.

Version 0, edited 3 years ago by stephenh1988 (next)

comment:10 @wonderboymusic13 months 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

comment:11 @wonderboymusic13 months ago

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