The function call
get_terms('post_tag', 'fields=names')
is expected to return an array containing all tag names. An empty array is returned instead.
get_terms('post_tag', 'fields=ids')
returns an array with all tag IDs as expected.
This error is the result of wrong operator and a missing if-condition in taxonomy.php:
Current code (starting from line 572:
else if ( 'names' == $fields )
$select_this == 't.name';
$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $number";
if ( 'all' == $fields ) {
$terms = $wpdb->get_results($query);
update_term_cache($terms);
} else if ( 'ids' == $fields ) {
$terms = $wpdb->get_col($query);
}
Fixed code:
else if ( 'names' == $fields )
$select_this = 't.name';
$query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $number";
if ( 'all' == $fields ) {
$terms = $wpdb->get_results($query);
update_term_cache($terms);
} else if ( ('ids' == $fields) || ('names' == $fields) ) {
$terms = $wpdb->get_col($query);
}