Don't require category__in, tag__in etc. to be arrays necessarily. Fixes #14892

git-svn-id: http://svn.automattic.com/wordpress/trunk@15626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-09-17 22:27:22 +00:00
parent 17c867e74b
commit 168659371d
1 changed files with 23 additions and 27 deletions

View File

@ -1286,34 +1286,30 @@ class WP_Query {
if ( empty($qv['cat']) || ($qv['cat'] == '0') ) { if ( empty($qv['cat']) || ($qv['cat'] == '0') ) {
$this->is_category = false; $this->is_category = false;
} else { } else {
if ( strpos($qv['cat'], '-') !== false ) { $this->is_category = strpos($qv['cat'], '-') !== false;
$this->is_category = false;
} else {
$this->is_category = true;
}
} }
if ( '' != $qv['category_name'] ) { if ( !empty($qv['category_name']) ) {
$this->is_category = true; $this->is_category = true;
} }
if ( !is_array($qv['category__in']) || empty($qv['category__in']) ) { if ( empty($qv['category__in']) ) {
$qv['category__in'] = array(); $qv['category__in'] = array();
} else { } else {
$qv['category__in'] = array_map('absint', $qv['category__in']); $qv['category__in'] = array_map('absint', (array) $qv['category__in']);
$this->is_category = true; $this->is_category = true;
} }
if ( !is_array($qv['category__not_in']) || empty($qv['category__not_in']) ) { if ( empty($qv['category__not_in']) ) {
$qv['category__not_in'] = array(); $qv['category__not_in'] = array();
} else { } else {
$qv['category__not_in'] = array_map('absint', $qv['category__not_in']); $qv['category__not_in'] = array_map('absint', (array) $qv['category__not_in']);
} }
if ( !is_array($qv['category__and']) || empty($qv['category__and']) ) { if ( empty($qv['category__and']) ) {
$qv['category__and'] = array(); $qv['category__and'] = array();
} else { } else {
$qv['category__and'] = array_map('absint', $qv['category__and']); $qv['category__and'] = array_map('absint', (array) $qv['category__and']);
$this->is_category = true; $this->is_category = true;
} }
@ -1321,40 +1317,40 @@ class WP_Query {
$this->is_tag = true; $this->is_tag = true;
$qv['tag_id'] = absint($qv['tag_id']); $qv['tag_id'] = absint($qv['tag_id']);
if ( !empty($qv['tag_id']) ) if ( !empty($qv['tag_id']) )
$this->is_tag = true; $this->is_tag = true;
if ( !is_array($qv['tag__in']) || empty($qv['tag__in']) ) { if ( empty($qv['tag__in']) ) {
$qv['tag__in'] = array(); $qv['tag__in'] = array();
} else { } else {
$qv['tag__in'] = array_map('absint', $qv['tag__in']); $qv['tag__in'] = array_map('absint', (array) $qv['tag__in']);
$this->is_tag = true; $this->is_tag = true;
} }
if ( !is_array($qv['tag__not_in']) || empty($qv['tag__not_in']) ) { if ( empty($qv['tag__not_in']) ) {
$qv['tag__not_in'] = array(); $qv['tag__not_in'] = array();
} else { } else {
$qv['tag__not_in'] = array_map('absint', $qv['tag__not_in']); $qv['tag__not_in'] = array_map('absint', (array) $qv['tag__not_in']);
} }
if ( !is_array($qv['tag__and']) || empty($qv['tag__and']) ) { if ( !is_array($qv['tag__and']) || empty($qv['tag__and']) ) {
$qv['tag__and'] = array(); $qv['tag__and'] = array();
} else { } else {
$qv['tag__and'] = array_map('absint', $qv['tag__and']); $qv['tag__and'] = array_map('absint', (array) $qv['tag__and']);
$this->is_category = true;
}
if ( !is_array($qv['tag_slug__in']) || empty($qv['tag_slug__in']) ) {
$qv['tag_slug__in'] = array();
} else {
$qv['tag_slug__in'] = array_map('sanitize_title', $qv['tag_slug__in']);
$this->is_tag = true; $this->is_tag = true;
} }
if ( !is_array($qv['tag_slug__and']) || empty($qv['tag_slug__and']) ) { if ( empty($qv['tag_slug__in']) ) {
$qv['tag_slug__in'] = array();
} else {
$qv['tag_slug__in'] = array_map('sanitize_title', (array) $qv['tag_slug__in']);
$this->is_tag = true;
}
if ( empty($qv['tag_slug__and']) ) {
$qv['tag_slug__and'] = array(); $qv['tag_slug__and'] = array();
} else { } else {
$qv['tag_slug__and'] = array_map('sanitize_title', $qv['tag_slug__and']); $qv['tag_slug__and'] = array_map('sanitize_title', (array) $qv['tag_slug__and']);
$this->is_tag = true; $this->is_tag = true;
} }