Prevent ambiguous table aliases in wp_post_mime_type_where. props stephdau, jfarthing84, fixes #12750.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
40da0a5720
commit
6c69044070
|
@ -1573,9 +1573,10 @@ function wp_match_mime_types($wildcard_mime_types, $real_mime_types) {
|
|||
* @since 2.5.0
|
||||
*
|
||||
* @param string|array $mime_types List of mime types or comma separated string of mime types.
|
||||
* @param string $table_alias Optional. Specify a table alias, if needed.
|
||||
* @return string The SQL AND clause for mime searching.
|
||||
*/
|
||||
function wp_post_mime_type_where($post_mime_types) {
|
||||
function wp_post_mime_type_where($post_mime_types, $table_alias = '') {
|
||||
$where = '';
|
||||
$wildcards = array('', '%', '%/%');
|
||||
if ( is_string($post_mime_types) )
|
||||
|
@ -1603,9 +1604,9 @@ function wp_post_mime_type_where($post_mime_types) {
|
|||
return '';
|
||||
|
||||
if ( false !== strpos($mime_pattern, '%') )
|
||||
$wheres[] = "post_mime_type LIKE '$mime_pattern'";
|
||||
$wheres[] = empty($table_alias) ? "post_mime_type LIKE '$mime_pattern'" : "$table_alias.post_mime_type LIKE '$mime_pattern'";
|
||||
else
|
||||
$wheres[] = "post_mime_type = '$mime_pattern'";
|
||||
$wheres[] = empty($table_alias) ? "post_mime_type = '$mime_pattern'" : "$table_alias.post_mime_type = '$mime_pattern'";
|
||||
}
|
||||
if ( !empty($wheres) )
|
||||
$where = ' AND (' . join(' OR ', $wheres) . ') ';
|
||||
|
|
|
@ -2026,13 +2026,14 @@ class WP_Query {
|
|||
$post_ids = get_objects_in_term($term_ids, $taxonomy);
|
||||
if ( !is_wp_error($post_ids) && !empty($post_ids) ) {
|
||||
$whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") ";
|
||||
if ( '' === $post_type ) {
|
||||
if ( empty($post_type) ) {
|
||||
$post_type = 'any';
|
||||
$post_status_join = true;
|
||||
} elseif ( in_array('attachment', (array)$post_type) ) {
|
||||
$post_status_join = true;
|
||||
}
|
||||
$q['post_status'] = 'publish';
|
||||
if ( empty($q['post_status']) )
|
||||
$q['post_status'] = 'publish';
|
||||
} else {
|
||||
$whichcat = " AND 0 ";
|
||||
}
|
||||
|
@ -2083,8 +2084,10 @@ class WP_Query {
|
|||
|
||||
// MIME-Type stuff for attachment browsing
|
||||
|
||||
if ( isset($q['post_mime_type']) && '' != $q['post_mime_type'] )
|
||||
$whichmimetype = wp_post_mime_type_where($q['post_mime_type']);
|
||||
if ( isset($q['post_mime_type']) && '' != $q['post_mime_type'] ) {
|
||||
$table_alias = $post_status_join ? $wpdb->posts : '';
|
||||
$whichmimetype = wp_post_mime_type_where($q['post_mime_type'], $table_alias);
|
||||
}
|
||||
|
||||
$where .= $search . $whichcat . $whichauthor . $whichmimetype;
|
||||
|
||||
|
|
Loading…
Reference in New Issue