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.

CommentFileSizeAuthor
#1 692988.views_.taxonomy-form-query.patch1.18 KBjoachim
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Status: Active » Needs review
FileSize
1.18 KB

Patch.

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!

merlinofchaos’s picture

the 'limit' option is the "Limit list to selected items". It should get set in the UI.

joachim’s picture

Is 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.

merlinofchaos’s picture

It 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.

merlinofchaos’s picture

Question: What if there are no vocabularies? (We may be problematic in the original case as well, I suppose).

esmerel’s picture

Bumping 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.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine.

merlinofchaos’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Ok, looks good. Committed to 6.x branches. Needs help to apply to 7.x

dawehner’s picture

Status: Patch (to be ported) » Fixed

Ported and commited.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.