[wp-trac] [WordPress Trac] #34660: Query breaks when nopaging = false and posts_per_page = -1

WordPress Trac noreply at wordpress.org
Wed Nov 11 21:53:21 UTC 2015


#34660: Query breaks when nopaging = false and posts_per_page = -1
-------------------------------------------------+-------------------------
 Reporter:  mgibbs189                            |       Owner:
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Query                                |  Release
 Severity:  normal                               |     Version:  trunk
 Keywords:  has-patch needs-docs needs-unit-     |  Resolution:
  tests                                          |     Focuses:
-------------------------------------------------+-------------------------

Comment (by boonebgorges):

 Replying to [comment:5 mgibbs189]:
 > > You might also say that when `nopaging=true`, `posts_per_page` should
 be ignored.
 >
 > @boonebgorges I appreciate the response, but that's an entirely separate
 issue.
 >
 > This ticket addresses the specific case when `posts_per_page = -1` and
 `nopaging = false`. In this scenario, `nopaging` '''must''' be ignored to
 prevent an SQL error.
 >
 > This is because -1 isn't a valid SQL limit, and forcing `nopaging =
 true` is the only way to bypass the LIMIT clause. Know what I mean?

 I understand the technical issue. What I'm saying is this. `nopaging =
 false` says "paginate results". `posts_per_page = -1` says "don't paginate
 results". They are the opposite of each other. Your patch says that, in
 such cases, `posts_per_page = -1` will always win. We could make the
 opposite decision, namely that `nopaging = false` should always win in
 such cases. (I said `nopaging = true` in my comment above, but I was
 getting confused by double-negatives. My bad.)

 I agree that it's probably correct for `posts_per_page = -1` to take
 precedence, because (a) `nopaging` kinda stinks, and (b) `nopaging` is
 disabled by default. But it's something that needs documentation, and
 especially tests that describe the decision we're making.

 We may also want to distinguish between `! isset( $q['nopaging'] )` and
 `false === $q['nopaging']`, because they have pretty different meanings in
 terms of the default `WP_Query` params.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34660#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list