[wp-trac] [WordPress Trac] #29908: date_query inclusive logic still not quite right
WordPress Trac
noreply at wordpress.org
Sun Oct 12 00:35:54 UTC 2014
#29908: date_query inclusive logic still not quite right
-----------------------------+-----------------------------
Reporter: magicroundabout | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Future Release
Component: Query | Version: 4.0
Severity: normal | Resolution:
Keywords: needs-patch | Focuses:
-----------------------------+-----------------------------
Changes (by boonebgorges):
* keywords: => needs-patch
* milestone: Awaiting Review => Future Release
Comment:
Confirmed. See [attachment:29908.test.patch] for an automated test that
illustrates the issue.
The root of the problem is that when you pass a string value as 'before'
or 'after', no "inclusive" logic is run: it's converted to 'Y-m-d H:i:s'
and passed back to the SQL generator. See line 349.
There are a couple ways to fix this for WP. Probably the most thorough is
to convert string values into year/month/day/hour/minute/second arrays,
and then run it through the rest of the logic of `build_mysql_datetime()`
to convert it back to MySQL format.
magicroundabout - For your specific case, you can workaround this issue by
either (a) using an array `'before' => array( 'year' => 2013, 'month' =>
10, 'day' => 13 )`, or (b) creating a more precise date string `'before'
=> '2013-01-13 23:59:59'`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29908#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list