Opened 10 years ago
Closed 10 years ago
#31001 closed defect (bug) (fixed)
New notices and warnings in WP_Date_Query
Reported by: | dlh | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 4.1.1 | Priority: | normal |
Severity: | normal | Version: | 4.1 |
Component: | Query | Keywords: | has-patch fixed-major commit |
Focuses: | Cc: |
Description
Some parameters of WP_Date_Query
now generate Array to string conversion
and _doing_it_wrong()
notices when passed an array.
For example:
new WP_Query( array( 'date_query' => array( array( 'compare' => 'BETWEEN', 'day' => array( 4, 7 ), ), ), ) );
new WP_Query( array( 'date_query' => array( array( 'compare' => 'BETWEEN', 'dayofweek' => array( 2, 6 ), ), ), ) );
dayofyear
, month
, year
, week
, and hour
, minute
, and second
also generate notices.
Passing an array to year
also generates new warnings:
mktime() expects parameter 6 to be long, array given in /wp-includes/date.php on line 309
DateTime::setISODate() expects parameter 1 to be long, array given in /wp-includes/date.php on line 342
Related: #29822.
Attachments (2)
Change History (11)
#3
@
10 years ago
boonebgorges: I tested the patch against my original queries, and each query worked as expected without notices or warnings.
One minor question: If my array has two incorrect values, such as 'hour' => array( 0, 25 )
, should I get two notices? Right now I get only a notice for the 0
.
Thanks also for pointing me to the better source of context for this in #25834.
#4
@
10 years ago
dlh - Thanks for having a look. I'll make a fix to ensure that notices are thrown for all incorrect values.
#5
@
10 years ago
- Owner set to boonebgorges
- Resolution set to fixed
- Status changed from new to closed
In 31179:
#6
@
10 years ago
- Keywords fixed-major commit added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for 4.1.1 consideration.
#7
@
10 years ago
31001.2.patch attempts to update the documentation with the support for arrays, but I'm not sure about the best way to handle the repetition involved.
Thanks for the ticket and for the research, dlh. Date validation was introduced in [29925] #25834, but it did not properly account for arrays being passed as the value of 'day', 'dayofweek', etc.
31001.diff should fix the problem. Could you give it a look?