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) {
CommentFileSizeAuthor
#5 1406634-5-search_environments-fix.patch2.43 KBjanusman
#4 Couple-of-fixes.patch10.02 KBAnonymous (not verified)

Comments

mariotux’s picture

I have the same problem, and this patch doesn't resolve it. Someone have this problem? Any ideas?

laroccadahouse’s picture

i 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.

allan1015’s picture

Just 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).

Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new10.02 KB

Here 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!

janusman’s picture

Assigned: Unassigned » janusman
StatusFileSize
new2.43 KB

Thanks @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.

inforeto’s picture

Patch from #5 got rid of the error, which otherwise shows up in every page.

(didn't try the patch from #4)

cpliakas’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #5 works as advertised.

Anonymous’s picture

patch worked for me!

thanks!

cpliakas’s picture

Status: Reviewed & tested by the community » Fixed
janusman’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Fixed » Active

Does 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.

kanikakhatriblc’s picture

please help me i am fresher in drupal. didn't get this error.missing argument 1 for apachesolr_has_searched()