Wrap each bit of distrib queue handler's saving operation in a try/catch; log exceptions but let everything else continue.

This commit is contained in:
Brion Vibber 2010-01-28 22:26:58 -08:00
parent 288dc3452f
commit ccb678ad15

View File

@ -62,23 +62,60 @@ class DistribQueueHandler
{
// XXX: do we need to change this for remote users?
try {
$notice->saveTags();
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
$groups = $notice->saveGroups();
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
$recipients = $notice->saveReplies();
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
$notice->addToInboxes($groups, $recipients);
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
$notice->saveUrls();
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
Event::handle('EndNoticeSave', array($notice));
// Enqueue for other handlers
} catch (Exception $e) {
$this->logit($notice, $e);
}
try {
common_enqueue_notice($notice);
} catch (Exception $e) {
$this->logit($notice, $e);
}
return true;
}
protected function logit($notice, $e)
{
common_log(LOG_ERR, "Distrib queue exception saving notice $notice->id: " .
$e->getMessage() . ' ' .
str_replace("\n", " ", $e->getTraceAsString()));
// We'll still return true so we don't get stuck in a loop
// trying to run a bad insert over and over...
}
}