Logging Solr communication exceptions as warnings

Before we didn't catch exceptions, the CMS would break when communication
errors with Solr occurred, this change will log those exceptions as warnings
so that creating new and publishing pages will continue gracefully.
This commit is contained in:
Sean Harvey 2013-02-13 09:52:06 +13:00
parent be2b45123f
commit 4f58937636
1 changed files with 19 additions and 3 deletions

View File

@ -167,7 +167,12 @@ abstract class SolrIndex extends SearchIndex {
if ($field['base'] == $base) $this->_addField($doc, $object, $field);
}
$this->getService()->addDocument($doc);
try {
$this->getService()->addDocument($doc);
} catch (Exception $e) {
SS_Log::log($e, SS_Log::WARN);
return false;
}
return $doc;
}
@ -195,11 +200,22 @@ abstract class SolrIndex extends SearchIndex {
function delete($base, $id, $state) {
$documentID = $this->getDocumentIDForState($base, $id, $state);
$this->getService()->deleteById($documentID);
try {
$this->getService()->deleteById($documentID);
} catch (Exception $e) {
SS_Log::log($e, SS_Log::WARN);
return false;
}
}
function commit() {
$this->getService()->commit(false, false, false);
try {
$this->getService()->commit(false, false, false);
} catch (Exception $e) {
SS_Log::log($e, SS_Log::WARN);
return false;
}
}
/**