[wp-trac] [WordPress Trac] #39540: NOT EXISTS meta condition doesn't work if meta has NULL value.

WordPress Trac noreply at wordpress.org
Tue Jan 10 16:42:20 UTC 2017


#39540: NOT EXISTS meta condition doesn't work if meta has NULL value.
--------------------------+-----------------------------
 Reporter:  avahura       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:  4.7
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 It seems problem exists since meta query class release.

 Right now NOT EXISTS works only if meta doesn't exist at all, but if it
 has NULL value we got incorrect result. I understand that better not use
 NULL values with metas at all, but you allow to write NULL as meta value,
 so please add possibility to check it.

 Just need to change string in class-wp-meta-query.php:

 {{{
 $sql_chunks['where'][] = $alias . '.' . $this->meta_id_column . ' IS
 NULL';
 }}}

 For example on:

 {{{
 $sql_chunks['where'][] = "$alias.meta_value IS NULL";
 }}}

 And both cases will be covered.

 Thank you in advance.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39540>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list