After updating the Apache Solr module to 7.x-1.0-beta15 we got the following error message:
Warning: Missing argument 1 for apachesolr_has_searched(), called in /var/www/xxx/sites/all/modules/contrib/apachesolr_stats/apachesolr_stats.module on line 173 and defined in apachesolr_has_searched() (regel 935 van /var/www/xxx/sites/all/modules/contrib/apachesolr/apachesolr.module).
This is because apachesolr_has_searched now requires an env_id argument. The quick fix is to use apachesolr_default_environment() but obviously the stats will only work for the default search environment:
Index: apachesolr_stats.module
--- apachesolr_stats.module Base (BASE)
+++ apachesolr_stats.module Locally Modified (Based On LOCAL)
@@ -170,10 +170,10 @@
return;
}
- if (! apachesolr_has_searched()) {
+ if (!apachesolr_has_searched(apachesolr_default_environment())) {
return;
}
- $query = apachesolr_current_query();
+ $query = apachesolr_current_query(apachesolr_default_environment());
$response = apachesolr_static_response_cache($query->getSearcher());
$num_suggestions = 0;
if (isset($response->spellcheck) && isset($response->spellcheck->suggestions) && $response->spellcheck->suggestions != NULL) {| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 1406634-5-search_environments-fix.patch | 2.43 KB | janusman |
| #4 | Couple-of-fixes.patch | 10.02 KB | Anonymous (not verified) |
Comments
Comment #1
mariotux commentedI have the same problem, and this patch doesn't resolve it. Someone have this problem? Any ideas?
Comment #2
laroccadahouse commentedi had these same error issues and applied the patch. the error messages did not go away until I cleared the site cache. maybe try that.
Comment #3
allan1015 commentedJust to add that Iinstalled the patch, cleared cache and the problem seems ot have gone away.
Also this error was also occuring at the same time: adn so far its not reoccured
Notice: Undefined variable: env_id in apachesolr_has_searched() (line 944 of /home/mysite/public_html/sites/all/modules/apachesolr/apachesolr.module).
Comment #4
Anonymous (not verified) commentedHere is a patch for solving this issue, and also a couple of UI hidden issues
Hope it can be applied to the repo. Best regards!
Comment #5
janusman commentedThanks @javier for the patch. I needed to weed out some extraneous lines that are just formatting changes =) But nice of you catching my bad usage of type = "#markup" in the form build.
Here's a clean patch.
Needs review.
Comment #6
inforeto commentedPatch from #5 got rid of the error, which otherwise shows up in every page.
(didn't try the patch from #4)
Comment #7
cpliakas commentedThe patch in #5 works as advertised.
Comment #8
Anonymous (not verified) commentedpatch worked for me!
thanks!
Comment #9
cpliakas commentedCommitted at http://drupalcode.org/project/apachesolr_stats.git/commit/3d2ddcf.
Comment #10
janusman commentedDoes this need backporting to 6.x? I'm not yet familiar with 6.x-3.x of Apache Solr Search, so unsure if it uses the concept of search environments.
Comment #11
kanikakhatriblc commentedplease help me i am fresher in drupal. didn't get this error.missing argument 1 for apachesolr_has_searched()