[wp-trac] [WordPress Trac] #32762: Comment meta queries cannot be set in WP_Comment_Query via pre_get_comments
WordPress Trac
noreply at wordpress.org
Tue Jun 23 13:04:47 UTC 2015
#32762: Comment meta queries cannot be set in WP_Comment_Query via pre_get_comments
--------------------------+------------------
Reporter: needle | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 4.3
Component: Comments | Version: 4.2
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+------------------
Changes (by boonebgorges):
* keywords: => has-patch
* version: trunk => 4.2
* milestone: Awaiting Review => 4.3
Comment:
Thanks for the report, needle. I have a few thoughts about this.
First, there is definitely a regression for people who were doing
modification of the `meta_query` argument at `pre_get_comments`.
Second, it's not obvious to me how the example in
https://wordpress.org/support/topic/wordpress-421-pre_get_comments-doesnt-
work-after-update?replies=8 ever would have worked. Since comment meta
queries were introduced [22074], `parse_query_vars()` has been run
*before* `pre_get_comments`. That means that modifying
`$query->query_vars['meta_key']` should have had no effect.
All this being said, it seems to me to be a mistake that the meta query is
initialized at all before `pre_get_comments`, as it will inevitably lead
to cases like this. (For reference, `WP_Query` sets up its meta query just
*after* `pre_get_posts`
https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-
includes/query.php?marks=2396,2405,2406#L2385.) Moving the entire
meta_query block below `pre_get_comments` will probably introduce backward
compatibility issues for people who are expecting the meta_query to be set
up at the hook. So I'm going to suggest [attachment:32762.diff], which
reparses the query vars after `pre_get_comments`, and only then generates
the SQL clauses. needle, does this seem right to you?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/32762#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list