Changeset 27689
- Timestamp:
- 03/24/2014 07:56:54 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/meta.php
r27562 r27689 754 754 if ( 'OR' == $this->relation ) { 755 755 foreach ( $this->queries as $k => $q ) { 756 if ( ! array_key_exists( 'value', $q ) && ! empty( $q['key'] ) )756 if ( ( empty( $q['compare'] ) || 'NOT EXISTS' != $q['compare'] ) && ! array_key_exists( 'value', $q ) && ! empty( $q['key'] ) ) 757 757 $key_only_queries[$k] = $q; 758 758 else -
trunk/tests/phpunit/tests/meta/query.php
r26055 r27689 153 153 $this->assertEquals( 'CHAR', $query->get_cast_for_type( 'ANYTHING ELSE' ) ); 154 154 } 155 156 function test_not_exists() { 157 global $wpdb; 158 159 $query = new WP_Meta_Query( array( 160 'relation' => 'OR', 161 array( 162 'key' => 'exclude', 163 'compare' => 'NOT EXISTS' 164 ), 165 array( 166 'key' => 'exclude', 167 'compare' => '!=', 168 'value' => '1' 169 ), 170 ) ); 171 172 $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); 173 $this->assertNotContains( "{$wpdb->postmeta}.meta_key = 'exclude'\nOR", $sql['where'] ); 174 $this->assertContains( "{$wpdb->postmeta}.post_id IS NULL", $sql['where'] ); 175 } 176 177 function test_empty_compare() { 178 global $wpdb; 179 180 $query = new WP_Meta_Query( array( 181 'relation' => 'OR', 182 array( 183 'key' => 'exclude', 184 'compare' => '' 185 ), 186 array( 187 'key' => 'exclude', 188 'compare' => '!=', 189 'value' => '1' 190 ), 191 ) ); 192 193 $sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this ); 194 $this->assertContains( "{$wpdb->postmeta}.meta_key = 'exclude'\nOR", $sql['where'] ); 195 $this->assertNotContains( "{$wpdb->postmeta}.post_id IS NULL", $sql['where'] ); 196 } 155 197 }
Note: See TracChangeset
for help on using the changeset viewer.