WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 19 months ago

#17853 new defect (bug)

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

Reported by: anmari Owned by:
Milestone: Awaiting Review 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 2 years ago.
ssmathias posts_per_rss patch file

Download all attachments as: .zip

Change History (10)

comment:1 xknown3 years ago

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

comment:2 solarissmoke2 years ago

  • Keywords close added

xknown's solution works.

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

ssmathias2 years ago

ssmathias posts_per_rss patch file

comment:4 ssmathias2 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 ssmathias2 years ago

  • Cc steve@… added

comment:6 ssmathias2 years ago

  • Keywords has-patch added

comment:7 tollmanz23 months ago

  • Cc zack@… added

comment:8 stephenh198819 months ago

  • Cc contact@… added

comment:9 stephenh198819 months 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 19 months ago by stephenh1988 (previous) (diff)
Note: See TracTickets for help on using tickets.