As far as I can tell, what this code in views_handler_filter_term_node_tid does is get all vocabs, then query {vocabulary} again to find the lowest vocab ID, to set this as the default value.
Firstly this is not going to give you the first vocab in the list, as the user may have reordered them and put the vocab with the lowest vid below others.
Second, the query us needless as we already have to hand $vocabularies, which is indexed by vid, and to boot, in the right weight order!
So we just in fact want the first element in $vocabularies.
$vocabularies = taxonomy_get_vocabularies();
foreach ($vocabularies as $voc) {
$options[$voc->vid] = check_plain($voc->name);
}
if ($this->options['limit']) {
// We only do this when the form is displayed so this query doesn't run
// unnecessarily just when the object is constructed.
if ($this->options['vid'] == 0) {
$this->options['vid'] = db_result(db_query('SELECT MIN(vid) FROM {vocabulary} v'));
}
Patch coming.
Comments
Comment #1
joachim commentedPatch.
I reckon the check on $this->options['limit'] could perhaps be taken out, though I'm a bit confused by $this->options['limit'], because it *never gets set* other than in defaults!
Comment #2
merlinofchaos commentedthe 'limit' option is the "Limit list to selected items". It should get set in the UI.
Comment #3
joachim commentedIs that in a higher up class then? I see nothing in this one that assigns it. And there's no "Limit list to selected items" option in the UI that I can see -- though this is all for another issue, probably. The patch here fixes what it sets out to fix :)
This is the Taxonomy: Term filter, btw.
Comment #4
merlinofchaos commentedIt only shows up if 1) the filter is exposed and 2) the filter is set to use Dropdown, not autocomplete. If both of those are true it will then show up beneath "Remember" in the filter settings.
Comment #5
merlinofchaos commentedQuestion: What if there are no vocabularies? (We may be problematic in the original case as well, I suppose).
Comment #6
esmerel commentedBumping this up in the 'needs review' list; this looks like it might need to be set back to 'needs work', but I'm going to ask someone more qualified than me to make that call.
Comment #7
dawehnerLooks fine.
Comment #8
merlinofchaos commentedOk, looks good. Committed to 6.x branches. Needs help to apply to 7.x
Comment #9
dawehnerPorted and commited.