Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.12.2.159
diff -u -r1.1.2.12.2.159 apachesolr.module
--- apachesolr.module	23 Jul 2009 14:08:42 -0000	1.1.2.12.2.159
+++ apachesolr.module	14 Aug 2009 19:08:27 -0000
@@ -124,18 +124,11 @@
     $host = variable_get('apachesolr_host', 'localhost');
     $port = variable_get('apachesolr_port', 8983);
     $path = variable_get('apachesolr_path', '/solr');
-    $ping = FALSE;
-    try {
-      $solr = apachesolr_get_solr();
-      $ping = @$solr->ping(variable_get('apachesolr_ping_timeout', 4));
-      // If there is no $solr object, there is no server available, so don't continue.
-      if (!$ping) {
-        throw new Exception(t('No Solr instance available when checking requirements.'));
-      }
-    }
-    catch (Exception $e) {
-      watchdog('Apache Solr', nl2br(check_plain($e->getMessage())), NULL, WATCHDOG_ERROR);
+    $ping = apachesolr_server_status($host, $port, $path);
+    if (!$ping) {
+      watchdog('Apache Solr', 'No Solr instance available when checking requirements.', array(), WATCHDOG_ERROR);
     }
+
     $value =  $ping ? $t('Your site has contacted the Apache Solr server.') : $t('Your site was unable to contact the Apache Solr server.');
     $severity = $ping ? 0: 2;
     $description = theme('item_list', array($t('Host: %host', array('%host' => $host)),
@@ -1074,6 +1067,33 @@
 }
 
 /**
+ * Checks if a specific Apache Solr server is available.
+ *
+ * @return boolean TRUE if the server can be pinged, FALSE otherwise.
+ */
+function apachesolr_server_status($host = NULL, $port = NULL, $path = NULL) {
+  if (empty($host)) {
+    $host = variable_get('apachesolr_host', 'localhost');
+  }
+  if (empty($port)) {
+    $port = variable_get('apachesolr_port', '8983');
+  }
+  if (empty($path)) {
+    $path = variable_get('apachesolr_path', '/solr');
+  }
+
+  $ping = FALSE;
+  try {
+    $solr = apachesolr_get_solr($host, $port, $path);
+    $ping = @$solr->ping(variable_get('apachesolr_ping_timeout', 4));
+  }
+  catch (Exception $e) {
+    watchdog('Apache Solr', check_plain($e->getMessage()), NULL, WATCHDOG_ERROR);
+  }
+  return $ping;
+}
+
+/**
  * It is important to hold on to the Solr response object for the duration of the
  * page request so that we can use it for things like building facet blocks.
  */
