WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#31036 closed defect (bug) (fixed)

WP_Date_Query docblock doesn't properly describe array inputs

Reported by: boonebgorges Owned by: DrewAPicture
Milestone: 4.2 Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch
Focuses: docs Cc:

Description

See https://core.trac.wordpress.org/ticket/31001#comment:7 and https://core.trac.wordpress.org/attachment/ticket/31001/31001.2.patch

Many of the params in WP_Date_Query accept arrays rather than ints - and, indeed, BETWEEN and NOT BETWEEN *require* arrays - but the documentation doesn't make this clear.

Attachments (1)

31036.diff (5.6 KB) - added by boonebgorges 5 years ago.

Download all attachments as: .zip

Change History (5)

@boonebgorges
5 years ago

#1 @boonebgorges
5 years ago

DrewAPicture - If you have a moment, could you give your feedback on 31036.diff? The rub is that a bunch of parameters that normally require int values accept or even require array values when used in conjunction with certain values of compare. This is a hard (and redundant) thing to spell out in the array hash, so I've added a paragraph to the long description. What do you think?

#2 @DrewAPicture
5 years ago

  • Owner set to DrewAPicture
  • Status changed from new to reviewing

#3 @DrewAPicture
5 years ago

  • Keywords has-patch added

#4 @DrewAPicture
5 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 31336:

Clarify inline documentation for WP_Date_Query to better explain the relationship between an individual clause's 'compare' argument and various integer-based date arguments.

If the 'compare' argument equals 'IN' or 'NOT IN', arrays of any number of specific, valid values are accepted and simply considered based on the value of 'operator' (OR or AND). If the 'compare' argument is a range such as 'BETWEEN' or 'NOT BETWEEN', arrays of only two valid values are accepted.

Props boonebgorges.
Fixes #31036.

Note: See TracTickets for help on using tickets.