The default views filter handler makes assumptions about the operators in use when a submitted value is not an array. However, force single in exposed filters has the effect of making values submitted from a filter defined as #multiple to come through as a single value. As a result, you get a SQL query that looks like [fieldname] OR [filtervalue], which of course results in 0 results. Should be [fieldname] IN([filtervalue]). The first few lines of views_handler_filter_default could be updated as follows. Not entirely sure of further implications:

function views_handler_filter_default($op, $filter, $filterinfo, &$query) { 
  $table = $filterinfo['table'];
  $field = $filterinfo['field'];

  if(!is_array($filter['value']) && $filterinfo['value']['#multiple']) $filter['value'] = array($filter['value']);

Comments

onelittleant’s picture

Ok, there's actually better logic to apply in views_handler_filter_default. Instead of the above, it would be appropriate to check the operator that is in use when we are dealing with a singleton filter value. The better change would be to change the last few lines of the function to (apologies, not familiar w/patches at this point):

  else {
    if($filter['operator'] == 'OR' || $filter['operator'] == 'AND') $filter['operator'] = '=';
    if($filter['operator'] == 'NOR') $filter['operator'] = '<>';
    $query->ensure_table("$table");
    $query->add_where("%s.%s %s '%s'", $query->use_alias_prefix . $table, $field, $filter['operator'], $filter['value']);
  }
}
drupdrips’s picture

Good work!! I got bitten by this and your fix works for me. I also verified the query output from DEVEL and it is working for me at least. Thanks for tackling this.

sun’s picture

Status: Active » Postponed (maintainer needs more info)

Please supply a proper patch.

esmerel’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

No update for more than 30 days.