Getting this one on an Acquia hosted Drupal 6 site running on 8 servers. NewRelic came up with the root cause here:
in apachesolr_l called at /mnt/www/html//docroot/sites/all/modules/contrib/apachesolr/apachesolr.module (1816)
The problem:
/**
* Static getter/setter for the current query
*
* @todo reverse the order of parameters in future branches.
*/
function apachesolr_current_query($query = NULL, $namespace = 'apachesolr_search') {
static $saved_query = array();
if (is_object($query)) {
$saved_query[$namespace] = clone $query;
}
return is_object($saved_query[$namespace]) ? clone $saved_query[$namespace] : NULL;
}
/*** As you can see, the function above can return NULL in some cases! ***/
[...]
// Retain GET parameters that ApacheSolr knows nothing about.
$query = apachesolr_current_query();
$get = array_diff_key($_GET, array('q' => 1, 'page' => 1), $options['query'], $query->get_url_queryvalues());
$options['query'] += $get;
/*** The code above does absolutely no check on $query being NULL or not, resulting in the error mentioned in the subject of this issue. ***/
Proposed solution:
// Retain GET parameters that ApacheSolr knows nothing about.
$query = apachesolr_current_query();
if ($query) {
$get = array_diff_key($_GET, array('q' => 1, 'page' => 1), $options['query'], $query->get_url_queryvalues());
$options['query'] += $get;
}
Whatever the cause of the apachesolr_current_query() returning NULL doesn't even matter in this example, the state should be checked before simply assuming it's an object and handling it as such.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | apachesolr-2120217-get_url_queryvalues_3.patch | 1.83 KB | malc0mn |
| #2 | apachesolr-2120217-get_url_queryvalues_2.patch | 1.83 KB | malc0mn |
| #1 | apachesolr-2120217-get_url_queryvalues.patch | 1.77 KB | malc0mn |
Comments
Comment #1
malc0mn commentedPatch in attach.
Maybe this one is somehow related: https://drupal.org/node/1378544 ?
Comment #2
malc0mn commentedHmz, patch in attach is more correct I bet...
Comment #3
malc0mn commentedHow to trigger the testbot? My last attempt...
Comment #5
pwolanin commentedLooks like the bot is just confused.
Can you re-roll without the whitespace changes?