[wp-trac] [WordPress Trac] #33341: WP_Meta_Query IN operator with empty array does not return expected result

WordPress Trac noreply at wordpress.org
Wed Aug 19 22:39:58 UTC 2015


#33341: WP_Meta_Query IN operator with empty array does not return expected result
--------------------------+------------------------------
 Reporter:  flixos90      |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:  3.2
 Severity:  normal        |  Resolution:
 Keywords:  dev-feedback  |     Focuses:
--------------------------+------------------------------
Changes (by flixos90):

 * keywords:  reporter-feedback => dev-feedback


Comment:

 Hi Helen, yes that works indeed, so it is not really a functional problem.
 It probably depends on the point of view, but I personally would not
 expect the condition to be discarded. I would think that it is processed
 like the other conditions, causing the query (in my case) to return no
 posts at all.

 As far as I checked in core, the query is sent to MySQL, but it is
 basically being discarded by MySQL, so it does not happen directly in
 core. But the behavior is, like I said, just not the one I was expecting -
 why would any condition in a meta query be discarded? I would propose to
 manually work around that in the code by ignoring the condition only if it
 happens within an `'or'` relation with at least one more condition
 provided (since it is not relevant in this case), but otherwise by
 returning an empty array immediately (since this condition does not apply
 to any post).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33341#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list