Hi,

As soon as I'm adding 'Indexed Node: Item language' as Filter Criteria, I'm getting the following message:

Notice: Undefined index: options in SearchApiViewsHandlerFilterLanguage->admin_summary() (line 31 of .../modules/search_api/contrib/search_api_views/includes/handler_filter_language.inc).

Any idea how to get ride of it?

Thanks for help.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stone_d’s picture

The same here ... just after updated core and some other modules :/
Any ideas yet?

Thanks in advance for any hint.

Cyclodex’s picture

It looks like it has to do with the changes from latest version when I compare the
public function admin_summary() {

It looks like

// Remove every element which is not known.
foreach ($this->value as $i => $value) {
  if (!isset($this->definition['options'][$value])) {
    unset($this->value[$i]);
  }
}

was replaced with:

// Remove every element which is not known.
$this->get_value_options();
foreach ($this->value as $i => $value) {
  if (!isset($this->value_options[$value])) {
    unset($this->value[$i]);
  }
}

So when I dpm() the variables and arrays it shows me that there is no option "current" available, but this is the one I have selected in there.
So it looks like there is something not correct with the language field and the way it is getting the options...

$value:

value => current

$this->value_options:

options =>
... (Array, 3 elements)
und (String, 16 characters ) Language neutral
en (String, 7 characters ) English
de (String, 6 characters ) German

The filter criterion: "Indexed Node: Item language" has for me the following options:
- current user's language (current)
- default site language (default)
- language neutral (und)
- English (en)
- German (de)

So I hope this helps to find or fix the issue.

I am not sure what we have to do to get the right values, or why the get_value_options is not getting the right values...

Cheers!

Cyclodex’s picture

Not yet a patch, but here how I fixed it for now, please investigate and fix it if you know how to do it right :)

It looks like the following change will fix the error messages, the question is still, if the definition options are needed or not:

handler_filter_language.inc

/**
* Provides a summary of this filter's value for the admin UI.
*/
public function admin_summary() {
  // TODO defintion options seem not to be set always:
  $tmp = array();
  if (!empty($this->definition['options'])){
    $tmp = $this->definition['options'];
  }
  // TODO are the following 2 definition options needed ?
  //  $this->definition['options']['current'] = t('current');
  //  $this->definition['options']['default'] = t('default');
  $this->value_options['current'] = t('current');
  $this->value_options['default'] = t('default');
  $ret = parent::admin_summary();
  $this->definition['options'] = $tmp;
  return $ret;
}

This at least solves my error messages and shows the right language "current" selection again.

ezeedub’s picture

Here's a patch.

drunken monkey’s picture

Status: Active » Needs review
FileSize
1.28 KB

Thanks for reporting this issue and providing a patch!
However, I think the attached one makes the filter a lot simpler and should also resolve the issue pretty well. Please test/review!

IRuslan’s picture

Patch works for me.

drunken monkey’s picture

Status: Needs review » Fixed

Great to hear, thanks for testing!
Committed.

Status: Fixed » Closed (fixed)

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