Opened 12 years ago
Closed 11 years ago
#31001 closed defect (bug) (fixed)
New notices and warnings in WP_Date_Query
| Reported by: | dlh | Owned by: | boonebgorges |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.1.1 |
| Component: | Query | Version: | 4.1 |
| Severity: | normal | Keywords: | has-patch fixed-major commit |
| Cc: | Focuses: |
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 309DateTime::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
@
12 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
@
12 years ago
dlh - Thanks for having a look. I'll make a fix to ensure that notices are thrown for all incorrect values.
#6
@
12 years ago
- Keywords fixed-major commit added
- Resolution fixed
- Status closed → reopened
Reopening for 4.1.1 consideration.
#7
@
12 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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?