[wp-trac] [WordPress Trac] #49284: WP_Meta_Query's 'compare_key' does not support 'NOT EXISTS' when used with WP_User_Query
WordPress Trac
noreply at wordpress.org
Fri Jan 24 13:37:45 UTC 2020
#49284: WP_Meta_Query's 'compare_key' does not support 'NOT EXISTS' when used with
WP_User_Query
--------------------------+------------------------------
Reporter: gikaragia | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 5.3.2
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+------------------------------
Comment (by gikaragia):
To test this, I used SAVEQUERIES configuration. After applying the patch,
I observed that the following query is generated (which is correct):
{{{
SELECT DISTINCT wp_users.* FROM wp_users INNER JOIN wp_usermeta ON (
wp_users.ID = wp_usermeta.user_id ) INNER JOIN wp_usermeta AS mt1 ON (
wp_users.ID = mt1.user_id ) WHERE 1=1 AND ( ( wp_usermeta.meta_key =
'learner_calculated_version' AND wp_usermeta.meta_value != '3' ) OR NOT
EXISTS (SELECT 1 FROM wp_usermeta mt2 WHERE mt2.user_id = mt1.user_id AND
mt2.meta_key = 'learner_calculated_version' LIMIT 1) ) ORDER BY user_login
ASC
}}}
I also tried the patch with get_posts to ensure that it is not broken. The
query for get_posts was unchanged after the patch and it was:
{{{
SELECT wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID =
wp_postmeta.post_id ) INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID =
mt1.post_id ) WHERE 1=1 AND ( ( wp_postmeta.meta_key =
'learner_calculated_version' AND wp_postmeta.meta_value != '3' ) OR NOT
EXISTS (SELECT 1 FROM wp_postmeta mt2 WHERE mt2.post_ID = mt1.post_ID AND
mt2.meta_key = 'learner_calculated_version' LIMIT 1) ) AND
wp_posts.post_type = 'post' AND ((wp_posts.post_status = 'publish')) GROUP
BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 5
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49284#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list