[wp-trac] [WordPress Trac] #33372: WP_Query may return incorrect results when using negative values with parameter p.

WordPress Trac noreply at wordpress.org
Mon Aug 1 14:24:43 UTC 2016


#33372: WP_Query may return incorrect results when using negative values with
parameter p.
-------------------------------------------------+-------------------------
 Reporter:  giantrobot                           |       Owner:
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Query                                |  Release
 Severity:  normal                               |     Version:
 Keywords:  good-first-bug needs-patch needs-    |  Resolution:
  unit-tests                                     |     Focuses:
-------------------------------------------------+-------------------------
Changes (by boonebgorges):

 * keywords:  good-first-bug has-patch has-unit-tests => good-first-bug
     needs-patch needs-unit-tests


Comment:

 @kouratoras @Akeif Thanks for the patch and the test. A few
 notes/questions:

 1. @Akeif correctly points out that passing non-scalar values to 'p' will
 result in odd behavior. We should have unit tests that demonstrate our
 intended behavior.

 2. [attachment:WP_Query_returns_404_when_negative_p_parameter.33372.diff]
 doesn't address the non-scalar weirdness, since `intval()` will cast
 arrays and objects to `1`. Should we take this opportunity to fix that
 problem too? Something like: `if ( ! is_scalar( $p ) || $p < 0 ) { 404 }`,
 with the `intval()` typecasting happening after the check?

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


More information about the wp-trac mailing list