further meta query optimization. props aaroncampbell. fixes #9124

git-svn-id: http://svn.automattic.com/wordpress/trunk@15730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-10-05 23:06:20 +00:00
parent 7630099b45
commit ef709f8953
1 changed files with 8 additions and 10 deletions

View File

@ -557,7 +557,7 @@ class WP_Object_Query {
} }
$meta_query = array(); $meta_query = array();
foreach ( array( 'key', 'value', 'compare' ) as $key ) { foreach ( array( 'key', 'value', 'compare', 'type' ) as $key ) {
if ( ! empty( $qv[ "meta_$key" ] ) ) if ( ! empty( $qv[ "meta_$key" ] ) )
$meta_query[ $key ] = $qv[ "meta_$key" ]; $meta_query[ $key ] = $qv[ "meta_$key" ];
} }
@ -596,9 +596,7 @@ class WP_Object_Query {
if ( ! in_array( $meta_compare, array( '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'IN', 'BETWEEN' ) ) ) if ( ! in_array( $meta_compare, array( '=', '!=', '>', '>=', '<', '<=', 'LIKE', 'IN', 'BETWEEN' ) ) )
$meta_compare = '='; $meta_compare = '=';
if ( 'STRING' == $meta_type ) if ( 'NUMERIC' == $meta_type )
$meta_type = 'CHAR';
elseif ( 'NUMERIC' == $meta_type )
$meta_type = 'SIGNED'; $meta_type = 'SIGNED';
elseif ( ! in_array( $meta_type, array( 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED' ) ) ) elseif ( ! in_array( $meta_type, array( 'BINARY', 'CHAR', 'DATE', 'DATETIME', 'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED' ) ) )
$meta_type = 'CHAR'; $meta_type = 'CHAR';