when you set the i18n content selection mode to "all content" and use the i18n content negotiating filter in a view, the view results in an SQL error because the filter generates a "AND ()" in the where clause instead of just leaving the filter blank what should be dine when "all content" (=no filtering) is selected.

Comments

y_h’s picture

I've had the same problem and rewrote the file i18n/i18nviews/includes/content_negotiation_filter_handler.inc

fixed the "AND ()" error by throwing a simple check if the $where var was empty or not.
and for the filter to actually work i had to add 'strict' as the $mode argument for the i18n_db_rewrite_where function

fix:

class content_negotiation_filter_handler extends views_handler_filter {
  function query() {
    $table_alias = $this->query->ensure_table('node');
    $where = i18n_db_rewrite_where($table_alias, 'node','strict');
    if(!empty($where)){
      $this->query->add_where($this->options['group'], $where);
    }
  }
  
  function option_definition() {
    $options = parent::option_definition();
    $options['operator']['default'] = '';
    $options['value']['default'] = '';
    return $options;
  }
}
markus_petrux’s picture

Status: Active » Needs review
StatusFileSize
new1.03 KB

Attached patch fixes the above mentioned issue, and another issue that I've found in this handler: it builds the join and where clause against the node table, ignoring relationships. This is fixed using the $this->ensure_my_table() and getting the table alias from $this->table_alias.

jose reyero’s picture

Status: Needs review » Fixed

Fixed, thanks

Status: Fixed » Closed (fixed)

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