WordPress build repository browser

Changeset 29646


Ignore:
Timestamp:
10/14/2014 02:17:18 AM (11 years ago)
Author:
boonebgorges
Message:

Use only LEFT JOINs when a meta_query contains a NOT EXISTS clause.

Mixing LEFT and INNER JOIN in these cases results in posts with no metadata
being improperly excluded from results.

Props johnrom.
Fixes #29062.
Built from https://develop.svn.wordpress.org/trunk@29890

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/meta.php

    r29643 r29646  
    11231123
    11241124        $sql = $this->get_sql_clauses();
     1125
     1126        /*
     1127         * If any JOINs are LEFT JOINs (as in the case of NOT EXISTS), then all JOINs should
     1128         * be LEFT. Otherwise posts with no metadata will be excluded from results.
     1129         */
     1130        if ( false !== strpos( $sql['join'], 'LEFT JOIN' ) ) {
     1131            $sql['join'] = str_replace( 'INNER JOIN', 'LEFT JOIN', $sql['join'] );
     1132        }
    11251133
    11261134        /**
Note: See TracChangeset for help on using the changeset viewer.