[wp-trac] [WordPress Trac] #58200: Empty result when meta_query is supposed to select date less than certain date
WordPress Trac
noreply at wordpress.org
Wed Apr 26 17:53:16 UTC 2023
#58200: Empty result when meta_query is supposed to select date less than certain
date
--------------------------+-----------------------------
Reporter: oglekler | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
{{{
$args = [
'post_type' => 'page',
'posts_per_page' => '10',
'paged' => '1',
'meta_query' => [
'event' => [
'key' => 'event_end',
'value' => date( 'Y-m-d H:i:s' ),
'compare' => '<',
'type' => 'DATETIME'
],
];
}}}
Request will be:
{{{
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts INNER JOIN wp_postmeta ON (
wp_posts.ID = wp_postmeta.post_id )
WHERE 1=1 AND (
( wp_postmeta.meta_key = 'event_end' AND CAST(wp_postmeta.meta_value AS
DATETIME) < '2023-04-26 17:12:15' )
) AND wp_posts.post_type = 'page' AND ((wp_posts.post_status = 'publish'))
GROUP BY wp_posts.ID
ORDER BY CAST(wp_postmeta.meta_value AS DATETIME)
DESC
LIMIT 0, 10
}}}
And as a result, empty values will be among the result.
How to check:
1. Add to certain post_type post_meta event_end with empty value.
2. Create new WP_Query with this post_type and meta_query where event_end
is less than current date (look above).
3. Get post and check that selection has empty value.
Expected behaviour is to get all posts, where event_end post_meta has a
type of DATETIME and not empty.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58200>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list