[wp-trac] [WordPress Trac] #17066: $wp_query->found_posts is set to 0 with posts_per_page=-1
WordPress Trac
wp-trac at lists.automattic.com
Thu Aug 30 05:55:33 UTC 2012
#17066: $wp_query->found_posts is set to 0 with posts_per_page=-1
--------------------------+-----------------------------
Reporter: patrik bona | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Query | Version: 3.1
Severity: normal | Resolution:
Keywords: has-patch |
--------------------------+-----------------------------
Comment (by wonderboymusic):
My reading of {{{$q['no_found_rows']}}} is "don't do the
{{{FOUND_ROWS()}}} query" - doesn't mean that found_rows is forbidden from
being set, just don't use the query to do it. The query is also suppressed
if there is no limit, which to me means "set found_rows from {{{count(
$posts )}}} since we got all of the posts already"
I made a new patch that IMO is simpler and addresses the original purpose
of the ticket which is returning a number that isn't zero in an instance
like this:
{{{
$q = new WP_Query( array( 'posts_per_page' => -1 ) );
error_log( $q->found_posts );
exit();
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/17066#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list