I receive the following errors when attempting to perform a search result using a view created with Apache Solr Views:

Notice: Undefined index: page_id in apachesolr_multilingual_apachesolr_query_alter() (line 390 of .../apachesolr_multilingual/apachesolr_multilingual.module).
Notice: Undefined index: page_id in apachesolr_multilingual_apachesolr_query_alter() (line 392 of .../apachesolr_multilingual/apachesolr_multilingual.module).

This problem comes up because on line 285 $query is an instance of ApachesolrViewsSolrBaseQuery and when getContext() is called, it returns a $context without a 'page_id'; whereas when the search query is performed without views, $query is an instance of SolrBaseQuery, which returns a $context with 'page_id' set. Because 'page_id' is not set, $search_page is not properly returned on line 390.

Within the last few months, function apachesolr_multilingual_apachesolr_query_alter($query) was rewritten. The previous version did not have this problem.

Note: I have 7.x-1.x-dev (April 11) installed for both apachesolr and apachesolr_multilingual.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mkalkbrenner’s picture

Project: Apache Solr Multilingual » Apache Solr Views
Priority: Normal » Critical

There has been introduced a small API change in the apachesolr module: #1918030: Allow contrib modules to add custom settings to search pages

ApachesolrViewsSolrBaseQuery has to be adjusted accordingly. Maybe I will provide a patch the next days ...

jongagne’s picture

Hey mkalkbrenner, any progress on a patch? I'm happy to help you out if you like. Or if you have no time to work on it, I'll work on it if you provide some suggestions. Thanks.

jongagne’s picture

Title: Broken compatibility with Apache Solr Views (Undefined index: page_id) » Broken compatibility with Apache Solr Multilingual (Undefined index: page_id)
imoreno’s picture

any updates with this one? would love to test any patch.

Itzhak

sylus’s picture

I am also very interested in this issue. Can anyone provide any additional information to this issue? ^_^

sylus’s picture

I added the following to line 401 in apachesolr_multilingual.module which seems to make the error go away but just can't get apachesolr_views to search when apachesolr_mulitlingual is enabled.

$context['page_id'] = apachesolr_search_default_search_page();
sylus’s picture

Project: Apache Solr Views » Apache Solr Multilingual
FileSize
671 bytes

Attaching patch and moving to apachesolr_multilingual. Please move back if incorrect to do so.

mkalkbrenner’s picture

Title: Broken compatibility with Apache Solr Multilingual (Undefined index: page_id) » Broken compatibility with DrupalSolrQueryInterface causes Apache Solr Multilingual to fail (Undefined index: page_id)
Project: Apache Solr Multilingual » Apache Solr Views
FileSize
1.66 KB

Apache Solr Search Integration introduced the concept of search pages during the development of 7.x-1.x.
Every search page has it own settings including pre-defined filters.

For me it look like Apache Solr Views has been developed before search pages have been introduced or simply ignores that concept.

#1918030: Allow contrib modules to add custom settings to search pages improved the API for that concept. Now it's possible that a module like Apache Solr Multilingual can store individual multilingual settings for each search page instead a single global setting.
BTW that's why the patch in #7 is wrong, because it overrides all individual settings be the default one, even if Apache Solr Views is not involved.

I attached a patch that lets Apache Solr Views "use" the default search page settings. That should fix the critical issue for most users that only use one search page.

But the real fix will be to add a selection to the views setting page to select a search page setting to use for a particular view.

mkalkbrenner’s picture

Issue summary: View changes

added note

MiroslavBanov’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

I have to disagree with #8.

I don't think there is any compatibility problem with DrupalSolrQueryInterface in Apachesolr Views. ApachesolrViewsSolrBaseQuery extends the SolrBaseQuery, making a very trivial change. There is nothing about page_id in DrupalSolrQueryInterface or SolrBaseQuery.

mkalkbrenner’s picture

Status: Postponed (maintainer needs more info) » Active

The problem is in class apachesolr_views_query:

public function execute(&$view) {
  $query = new ApachesolrViewsSolrBaseQuery('apachesolr', $solr, $this->query_params, '', current_path());
}

It misses the new 6th parameter $context that has been introduced by #1918030: Allow contrib modules to add custom settings to search pages.
My patch from #8 ensures a minimal $context.

Apache Solr Multilingual replaced its global multilingual settings be settings per search page. This is absolutely correct and required in combination with Apache Solr. But it turns out that it breaks compatibility with 3rd party modules that don't use search pages. Therefor I see these ways to solve the problem:

- every 3rd party module (like Apache Solr Views) provides a search page id via context (see my patch #8)
- Apache Solr Multilingual provides additional settings per 3rd party module (too much work and not maintainable)
- we declare some 3rd party modules to be incompatible with Apache Solr Multilingual

MiroslavBanov’s picture

But the only parameters that are required for SolrBaseQuery class are the first two. Context is completely optional. Also, page_id is something that comes up in apachesolr_search module, and in the comments everywhere is written "search page id".

It doesn't make sense sense for apachesolr_views to pass "page_id". It's supposed to identify "search page". Apachesolr views is used for things like blocks, panel panes, media browsers. So even if we forget the "search page" part, it doesn't necessarily have anything to do with a page.

So I think that apachesolr_views is inheriting SolrBaseQuery correctly and is instantiating it correctly. I am not against passing some context that makes sense for apachesolr_views, I just think passing a context that is misleading is a potential problem that doesn't need to be introduced.

MiroslavBanov’s picture

Status: Active » Closed (works as designed)

This issue, the way it is defined right now in the title and summary, is not something that should be considered an unresolved bug in apachesolr_views. Passing page_id in context is not required, and I think it is incorrect to do that, as there is no relational between search pages and apachesolr_views.

Feel free to reopen if new information is available.

mkalkbrenner’s picture

I agree. The concept of search pages is incompatible with Apache Solr Views and therefor Apache Solr Multilingual is incompatible with Apache Solr Views, too. I'll implement a switch that turns of multilingual query altering if no seach page id is provided (until someone finds the time to write a full integration which is possible).

MiroslavBanov’s picture

Priority: Critical » Normal
Status: Closed (works as designed) » Active

There is now context in the latest dev version of apachesolr_views.

      $context = array(
        'search_type' => 'apachesolr_views_query',
        'view_name' => $view->name,
        'current_display' => $view->current_display,
      );

Feel free to close this ticket again if this context is not sufficient to add compatibility.

MiroslavBanov’s picture

Project: Apache Solr Views » Apache Solr Multilingual
stefan.r’s picture

Right now Apache Solr Multilingual is still broken with Apache Solr Views (as it still requires a page_id).

I'll implement a switch that turns of multilingual query altering if no seach page id is provided (until someone finds the time to write a full integration which is possible).

I don't think this has happened yet?

stefan.r’s picture

Status: Active » Needs review
FileSize
687 bytes