[wp-trac] [WordPress Trac] #41826: WP_Comment_Query can generate negative offset in LIMIT clause

WordPress Trac noreply at wordpress.org
Thu Sep 7 11:40:50 UTC 2017


#41826: WP_Comment_Query can generate negative offset in LIMIT clause
--------------------------+-----------------------------
 Reporter:  birgire       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 The {{{paged}}} argument in {{{WP_Comment_Query}}} was introduced in
 #38268

 There's a problem with the {{{paged}}} as 0 case.

 '''Example:'''

 When the {{{paged}}} is 0 and {{{number}}} is 2, {{{WP_Comment_Query}}}
 generates the LIMIT clause:

 {{{ LIMIT -2, 2 }}}

 instead of

 {{{ LIMIT 0, 2 }}}

 According to the MySQL documentation, the offset in the LIMIT clause
 shouldn't be negative:

 https://dev.mysql.com/doc/refman/5.7/en/select.html

 I think we should handle it in the same way as in {{{WP_Query}}}, where
 the 0 case is treated as the default, that is 1.

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


More information about the wp-trac mailing list