[wp-trac] [WordPress Trac] #28631: WP_User_Query should support -1 for the number parameter

WordPress Trac noreply at wordpress.org
Wed Jun 25 15:22:37 UTC 2014


#28631: WP_User_Query should support -1 for the number parameter
-------------------------+-----------------------------
 Reporter:  mordauk      |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Users        |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 In order to be consistent with WP_Query, I think WP_User_Query should
 accept `-1` as a valid value for the `number` parameter.

 If you want to perform a query that returns all posts, you pass `-1` for
 `posts_per_page` to WP_Query.

 If you try to do this with WP_User_Query, however, you get an SQL syntax
 error:


 {{{
 WordPress database error: [You have an error in your SQL syntax; check the
 manual that corresponds to your MySQL server version for the right syntax
 to use near '-1' at line 2]
 SELECT SQL_CALC_FOUND_ROWS wp_users.* FROM wp_users INNER JOIN wp_usermeta
 ON (wp_users.ID = wp_usermeta.user_id) WHERE 1=1 AND (
 (CAST(wp_usermeta.meta_value AS CHAR) LIKE '%\"pending\\_vendor\"%') ) AND
 (wp_usermeta.meta_key = 'wp_capabilities' ) ORDER BY user_login ASC LIMIT
 -1
 }}}

 `LIMIT` can't be `-1` in SQL.

 I'd expect both of these to return the same results:

 {{{
 $query = new WP_User_Query( array(
     'number' => -1
 ) );

 $query = new WP_User_Query( array(
     'number' => 99999999
 ) );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28631>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list