Changeset 21185 for trunk/wp-includes/meta.php
- Timestamp:
- 06/29/2012 07:59:29 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/meta.php
r20435 r21185 721 721 $meta_type = 'CHAR'; 722 722 723 $meta_value = isset( $q['value'] ) ? $q['value'] : null; 724 725 if ( isset( $q['compare'] ) ) 726 $meta_compare = strtoupper( $q['compare'] ); 727 else 728 $meta_compare = is_array( $meta_value ) ? 'IN' : '='; 729 730 if ( ! in_array( $meta_compare, array( 731 '=', '!=', '>', '>=', '<', '<=', 732 'LIKE', 'NOT LIKE', 733 'IN', 'NOT IN', 734 'BETWEEN', 'NOT BETWEEN', 735 'NOT EXISTS' 736 ) ) ) 737 $meta_compare = '='; 738 723 739 $i = count( $join ); 724 740 $alias = $i ? 'mt' . $i : $meta_table; 725 741 726 // Set JOIN 742 if ( 'NOT EXISTS' == $meta_compare ) { 743 $join[$i] = "LEFT JOIN $meta_table"; 744 $join[$i] .= $i ? " AS $alias" : ''; 745 $join[$i] .= " ON ($primary_table.$primary_id_column = $alias.$meta_id_column AND $alias.meta_key = '$meta_key')"; 746 747 $where[$k] = ' ' . $alias . '.' . $meta_id_column . ' IS NULL'; 748 749 continue; 750 } 751 727 752 $join[$i] = "INNER JOIN $meta_table"; 728 753 $join[$i] .= $i ? " AS $alias" : ''; … … 733 758 $where[$k] = $wpdb->prepare( "$alias.meta_key = %s", $meta_key ); 734 759 735 if ( !isset( $q['value']) ) {760 if ( is_null( $meta_value ) ) { 736 761 if ( empty( $where[$k] ) ) 737 762 unset( $join[$i] ); 738 763 continue; 739 764 } 740 741 $meta_value = $q['value'];742 743 $meta_compare = is_array( $meta_value ) ? 'IN' : '=';744 if ( isset( $q['compare'] ) )745 $meta_compare = strtoupper( $q['compare'] );746 747 if ( ! in_array( $meta_compare, array( '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'NOT LIKE', 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) )748 $meta_compare = '=';749 765 750 766 if ( in_array( $meta_compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) {
Note: See TracChangeset
for help on using the changeset viewer.