Ticket #18158: 18158.diff
File 18158.diff, 1.2 KB (added by , 13 years ago) |
---|
-
wp-includes/meta.php
724 724 $join[$i] .= $i ? " AS $alias" : ''; 725 725 $join[$i] .= " ON ($primary_table.$primary_id_column = $alias.$meta_id_column)"; 726 726 727 if( in_array( strtoupper( $q['compare'] ), array( 'EXISTS', 'NOT EXISTS' ) ) ) { 728 $join[$i] = "INNER JOIN $meta_table"; 729 $join[$i] .= $i ? " AS $alias" : ''; 730 $join[$i] .= " ON ($primary_table.$primary_id_column = $alias.$meta_id_column AND $alias.meta_key = '$meta_key')"; 731 } 732 727 733 $where[$k] = ''; 728 734 if ( !empty( $meta_key ) ) 729 735 $where[$k] = $wpdb->prepare( "$alias.meta_key = %s", $meta_key ); … … 771 777 $where[$k] .= ' AND '; 772 778 773 779 $where[$k] = ' (' . $where[$k] . $wpdb->prepare( "CAST($alias.meta_value AS {$meta_type}) {$meta_compare} {$meta_compare_string})", $meta_value ); 780 781 if( in_array( strtoupper( $q['compare'] ), array( 'EXISTS', 'NOT EXISTS' ) ) ) { 782 $where[$k] = ' (' . $alias.$meta_id_column . ' IS ' . ( ( strtoupper( $q['compare'] ) == 'EXISTS' ) ? 'NOT' : '' ) . ' NULL)'; 783 } 774 784 } 775 785 776 786 $where = array_filter( $where );