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.
Comment | File | Size | Author |
---|---|---|---|
#17 | 1969268-17.patch | 687 bytes | stefan.r |
#8 | 1969268_ensure_valid_context.patch | 1.66 KB | mkalkbrenner |
#7 | fix_missing_page_id-1969268-07.patch | 671 bytes | sylus |
Comments
Comment #1
mkalkbrennerThere 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 ...
Comment #2
jongagne CreditAttribution: jongagne commentedHey 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.
Comment #3
jongagne CreditAttribution: jongagne commentedComment #4
imoreno CreditAttribution: imoreno commentedany updates with this one? would love to test any patch.
Itzhak
Comment #5
sylus CreditAttribution: sylus commentedI am also very interested in this issue. Can anyone provide any additional information to this issue? ^_^
Comment #6
sylus CreditAttribution: sylus commentedI 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.
Comment #7
sylus CreditAttribution: sylus commentedAttaching patch and moving to apachesolr_multilingual. Please move back if incorrect to do so.
Comment #8
mkalkbrennerApache 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.
Comment #8.0
mkalkbrenneradded note
Comment #9
MiroslavBanov CreditAttribution: MiroslavBanov commentedI 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.
Comment #10
mkalkbrennerThe problem is in class apachesolr_views_query:
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
Comment #11
MiroslavBanov CreditAttribution: MiroslavBanov commentedBut 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.
Comment #12
MiroslavBanov CreditAttribution: MiroslavBanov commentedThis 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.
Comment #13
mkalkbrennerI 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).
Comment #14
MiroslavBanov CreditAttribution: MiroslavBanov as a volunteer commentedThere is now context in the latest dev version of apachesolr_views.
Feel free to close this ticket again if this context is not sufficient to add compatibility.
Comment #15
MiroslavBanov CreditAttribution: MiroslavBanov as a volunteer commentedComment #16
stefan.r CreditAttribution: stefan.r commentedRight now Apache Solr Multilingual is still broken with Apache Solr Views (as it still requires a page_id).
I don't think this has happened yet?
Comment #17
stefan.r CreditAttribution: stefan.r commented