Eliminate the use of `extract()` in `WP_Tax_Query::get_sql()`. All unit tests still pass.
See #22400. Built from https://develop.svn.wordpress.org/trunk@28422 git-svn-id: http://core.svn.wordpress.org/trunk@28249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e6fad96f5e
commit
80a37d2fcd
|
@ -738,17 +738,20 @@ class WP_Tax_Query {
|
||||||
foreach ( $this->queries as $index => $query ) {
|
foreach ( $this->queries as $index => $query ) {
|
||||||
$this->clean_query( $query );
|
$this->clean_query( $query );
|
||||||
|
|
||||||
if ( is_wp_error( $query ) )
|
if ( is_wp_error( $query ) ) {
|
||||||
return self::$no_results;
|
return self::$no_results;
|
||||||
|
}
|
||||||
|
|
||||||
extract( $query );
|
$terms = $query['terms'];
|
||||||
|
$operator = $query['operator'];
|
||||||
|
|
||||||
if ( 'IN' == $operator ) {
|
if ( 'IN' == $operator ) {
|
||||||
|
|
||||||
if ( empty( $terms ) ) {
|
if ( empty( $terms ) ) {
|
||||||
if ( 'OR' == $this->relation ) {
|
if ( 'OR' == $this->relation ) {
|
||||||
if ( ( $index + 1 === $count ) && empty( $where ) )
|
if ( ( $index + 1 === $count ) && empty( $where ) ) {
|
||||||
return self::$no_results;
|
return self::$no_results;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
return self::$no_results;
|
return self::$no_results;
|
||||||
|
@ -766,8 +769,9 @@ class WP_Tax_Query {
|
||||||
$where[] = "$alias.term_taxonomy_id $operator ($terms)";
|
$where[] = "$alias.term_taxonomy_id $operator ($terms)";
|
||||||
} elseif ( 'NOT IN' == $operator ) {
|
} elseif ( 'NOT IN' == $operator ) {
|
||||||
|
|
||||||
if ( empty( $terms ) )
|
if ( empty( $terms ) ) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$terms = implode( ',', $terms );
|
$terms = implode( ',', $terms );
|
||||||
|
|
||||||
|
@ -778,8 +782,9 @@ class WP_Tax_Query {
|
||||||
)";
|
)";
|
||||||
} elseif ( 'AND' == $operator ) {
|
} elseif ( 'AND' == $operator ) {
|
||||||
|
|
||||||
if ( empty( $terms ) )
|
if ( empty( $terms ) ) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$num_terms = count( $terms );
|
$num_terms = count( $terms );
|
||||||
|
|
||||||
|
@ -796,11 +801,11 @@ class WP_Tax_Query {
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $where ) )
|
if ( ! empty( $where ) ) {
|
||||||
$where = ' AND ( ' . implode( " $this->relation ", $where ) . ' )';
|
$where = ' AND ( ' . implode( " $this->relation ", $where ) . ' )';
|
||||||
else
|
} else {
|
||||||
$where = '';
|
$where = '';
|
||||||
|
}
|
||||||
return compact( 'join', 'where' );
|
return compact( 'join', 'where' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue