Problem/Motivation

When using entity translation to translate terms and having them as an exposed filter in a view, terms that don't have a translation are available as options but are lacking a label in the select widget.

This happens because entity_label('taxonomy_term', $entity_term) returns null as those terms don't have a label in the current language.

This is related to the change that was introduced with #1651726: Use entity_label instead of term name for term reference exposed filters.

Proposed resolution

Check the result of entity_label('taxonomy_term', $entity_term) and only add an option if there's an actual entity label.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

s_leu created an issue. See original summary.

s_leu’s picture

Status: Active » Needs review
FileSize
2.45 KB

Here's a patch that fixes this.

Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 3 year old patch in #2 to views_handler_filter_term_node_tid.inc does not apply to the latest views 7.x-3.x-dev and if still relevant needs to be rerolled.

Checking patch modules/taxonomy/views_handler_filter_term_node_tid.inc...
Hunk #1 succeeded at 130 (offset 34 lines).
error: while searching for:
        if ($tree) {
          // Translation system needs full entity objects, so we have access to label.
          foreach ($tree as $term) {
            $choice = new stdClass();
            $choice->option = array($term->tid => str_repeat('-', $term->depth) . entity_label('taxonomy_term', $term));
            $options[] = $choice;
          }
        }
      }

error: patch failed: modules/taxonomy/views_handler_filter_term_node_tid.inc:125
error: modules/taxonomy/views_handler_filter_term_node_tid.inc: patch does not apply
Andrew Answer’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.72 KB

Patch rerolled. Second hunk with $choice=stdClass() completely removed because of corresponding data structure is absent. Please review this patch.