Changeset 17674 for trunk/wp-includes/meta.php
- Timestamp:
- 04/21/2011 06:13:03 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/meta.php
r17530 r17674 388 388 foreach ( $meta_query as $q ) { 389 389 $meta_key = isset( $q['key'] ) ? trim( $q['key'] ) : ''; 390 $meta_value = isset( $q['value'] ) ? $q['value'] : '';391 390 $meta_compare = isset( $q['compare'] ) ? strtoupper( $q['compare'] ) : '='; 392 391 $meta_type = isset( $q['type'] ) ? strtoupper( $q['type'] ) : 'CHAR'; … … 414 413 $where .= $wpdb->prepare( " AND $alias.meta_key = %s", $meta_key ); 415 414 415 if ( !isset( $q['value'] ) ) 416 continue; 417 $meta_value = $q['value']; 418 416 419 if ( in_array( $meta_compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { 417 420 if ( ! is_array( $meta_value ) ) 418 421 $meta_value = preg_split( '/[,\s]+/', $meta_value ); 422 423 if ( empty( $meta_value ) ) 424 continue; 419 425 } else { 420 426 $meta_value = trim( $meta_value ); 421 427 } 422 423 if ( empty( $meta_value ) )424 continue;425 428 426 429 if ( 'IN' == substr( $meta_compare, -2) ) { … … 436 439 } 437 440 438 // @todo Temporary hack to support empty values. Do not use outside of core.439 if ( '_wp_zero_value' == $meta_value )440 $meta_value = 0;441 442 441 $where .= $wpdb->prepare( " AND CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$meta_compare_string}", $meta_value ); 443 442 } … … 458 457 459 458 // Simple query needs to be first for orderby=meta_value to work correctly 460 foreach ( array( 'key', ' value', 'compare', 'type' ) as $key ) {459 foreach ( array( 'key', 'compare', 'type' ) as $key ) { 461 460 if ( !empty( $qv[ "meta_$key" ] ) ) 462 461 $meta_query[0][ $key ] = $qv[ "meta_$key" ]; 463 462 } 464 463 464 // WP_Query sets 'meta_value' = '' by default 465 if ( isset( $qv[ 'meta_value' ] ) && '' !== $qv[ 'meta_value' ] ) 466 $meta_query[0]['value'] = $qv[ 'meta_value' ]; 467 465 468 if ( !empty( $qv['meta_query'] ) && is_array( $qv['meta_query'] ) ) { 466 469 $meta_query = array_merge( $meta_query, $qv['meta_query'] );
Note: See TracChangeset
for help on using the changeset viewer.