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.

Comments

malc0mn’s picture

Patch in attach.

Maybe this one is somehow related: https://drupal.org/node/1378544 ?

malc0mn’s picture

Hmz, patch in attach is more correct I bet...

malc0mn’s picture

Status: Active » Needs review
StatusFileSize
new1.83 KB

How to trigger the testbot? My last attempt...

Status: Needs review » Needs work

The last submitted patch, apachesolr-2120217-get_url_queryvalues_3.patch, failed testing.

pwolanin’s picture

Issue summary: View changes

Looks like the bot is just confused.

Can you re-roll without the whitespace changes?