In `WP_Query::get_queried_object()`, avoid PHP notices when `is_tax` is paired with an empty `tax_query`.
It's possible to have an empty `tax_query` and `is_tax=true` when the initial query contains a taxonomy var (and is processed as such during `WP_Query::parse_query()`) but the taxonomy var is unset during a 'parse_query' callback. While this kind of behavior is not necessarily something we need to support, we should continue to avoid PHP notices in such cases, as we did prior to WP 4.1. Fixes #31246. Built from https://develop.svn.wordpress.org/trunk@31366 git-svn-id: http://core.svn.wordpress.org/trunk@31347 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
09c1d34b96
commit
90639872e8
|
@ -3900,15 +3900,17 @@ class WP_Query {
|
|||
// For other tax queries, grab the first term from the first clause.
|
||||
$tax_query_in_and = wp_list_filter( $this->tax_query->queried_terms, array( 'operator' => 'NOT IN' ), 'NOT' );
|
||||
|
||||
$queried_taxonomies = array_keys( $tax_query_in_and );
|
||||
$matched_taxonomy = reset( $queried_taxonomies );
|
||||
$query = $tax_query_in_and[ $matched_taxonomy ];
|
||||
if ( ! empty( $tax_query_in_and ) ) {
|
||||
$queried_taxonomies = array_keys( $tax_query_in_and );
|
||||
$matched_taxonomy = reset( $queried_taxonomies );
|
||||
$query = $tax_query_in_and[ $matched_taxonomy ];
|
||||
|
||||
if ( $query['terms'] ) {
|
||||
if ( 'term_id' == $query['field'] ) {
|
||||
$term = get_term( reset( $query['terms'] ), $matched_taxonomy );
|
||||
} else {
|
||||
$term = get_term_by( $query['field'], reset( $query['terms'] ), $matched_taxonomy );
|
||||
if ( $query['terms'] ) {
|
||||
if ( 'term_id' == $query['field'] ) {
|
||||
$term = get_term( reset( $query['terms'] ), $matched_taxonomy );
|
||||
} else {
|
||||
$term = get_term_by( $query['field'], reset( $query['terms'] ), $matched_taxonomy );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.2-alpha-31365';
|
||||
$wp_version = '4.2-alpha-31366';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue