Opened 2 years ago
Last modified 8 months ago
#17853 new defect (bug)
Posts_per_page=-1 overwritten in query.php if is feed, (An ics feed needs all)
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Feeds | Version: | 3.2 |
| Severity: | normal | Keywords: | close has-patch |
| Cc: | steve@…, zack@…, contact@… |
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)
Change History (10)
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.
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:8
stephenh1988 — 8 months ago
- Cc contact@… added
comment:9
stephenh1988 — 8 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.

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