Index: Drupal_Apache_Solr_Service.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/Drupal_Apache_Solr_Service.php,v retrieving revision 1.1.2.21 diff -u -p -r1.1.2.21 Drupal_Apache_Solr_Service.php --- Drupal_Apache_Solr_Service.php 14 Oct 2009 19:08:19 -0000 1.1.2.21 +++ Drupal_Apache_Solr_Service.php 26 Oct 2009 02:00:24 -0000 @@ -185,6 +185,56 @@ class Drupal_Apache_Solr_Service extends } /** + * Make a request to a servlet (a path) that's not a standard path. + * + * @param string $servlet + * A path to be added to the base Solr path. e.g. 'extract/tika' + * + * @param array $params + * Any request parameters when constructing the URL. + * + * @param string $method + * 'GET', 'POST', 'PUT', or 'HEAD'. + * + * @param array $request_headers + * Keyed array of header names and values. Should include 'Content-Type' + * for POST or PUT. + * + * @param string $rawPost + * Must be an empty string unless method is POST or PUT. + * + * @param float $timeout + * Read timeout in seconds or FALSE. + * + * @return + * Apache_Solr_Response object + */ + public function makeServletRequest($servlet, $params = array(), $method = 'GET', $request_headers = array(), $rawPost = '', $timeout = FALSE) { + if ($method == 'GET' || $method == 'HEAD') { + // Make sure we are not sending a request body. + $rawPost = ''; + } + // Add default params. + $params += array( + 'wt' => self::SOLR_WRITER, + ); + + $url = $this->_constructUrl($servlet, $params); + list ($data, $headers) = $this->_makeHttpRequest($url, $method, $request_headers, $rawPost, $timeout); + $response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays); + $code = (int) $response->getHttpStatus(); + if ($code != 200) { + $message = $response->getHttpStatusMessage(); + if ($code >= 400 && $code != 403 && $code != 404) { + // Add details, like Solr's exception message. + $message .= $response->getRawResponse(); + } + throw new Exception('"' . $code . '" Status: ' . $message); + } + return $response; + } + + /** * Put Luke meta-data from the cache into $this->luke when we instantiate. * * @see Apache_Solr_Service::__construct() Index: apachesolr.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v retrieving revision 1.1.2.12.2.169 diff -u -p -r1.1.2.12.2.169 apachesolr.module --- apachesolr.module 22 Oct 2009 14:05:02 -0000 1.1.2.12.2.169 +++ apachesolr.module 26 Oct 2009 02:00:24 -0000 @@ -1041,6 +1041,10 @@ function apachesolr_facetcount_save($edi * } */ function apachesolr_modify_query(&$query, &$params, $caller) { + if (empty($query)) { + // This should only happen if Solr is not set up - avoids fatal errors. + return; + } foreach (module_implements('apachesolr_modify_query') as $module) { $function_name = $module . '_apachesolr_modify_query';