diff options
author | Brion Vibber <brion@pobox.com> | 2010-09-28 15:45:00 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-09-28 15:45:00 -0700 |
commit | 588758ed6d14a6c17eba9acf440164867c21cf25 (patch) | |
tree | a4a201ef17a40cfad02c05b614d31ba3287324ec /plugins/YammerImport/lib/yammerrunner.php | |
parent | 6cf7b2401754aef634d983187d87c9148e1f00ca (diff) |
Made YammerImport more robust against errors; can now pause/resume/reset the import state from the admin interface.
Diffstat (limited to 'plugins/YammerImport/lib/yammerrunner.php')
-rw-r--r-- | plugins/YammerImport/lib/yammerrunner.php | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/plugins/YammerImport/lib/yammerrunner.php b/plugins/YammerImport/lib/yammerrunner.php index e0aec0d16..3e53f3361 100644 --- a/plugins/YammerImport/lib/yammerrunner.php +++ b/plugins/YammerImport/lib/yammerrunner.php @@ -298,7 +298,10 @@ class YammerRunner $this->state->state = 'save-messages'; } else { foreach ($messages as $item) { - Yammer_notice_stub::record($item['id'], $item); + $stub = Yammer_notice_stub::staticGet($item['id']); + if (!$stub) { + Yammer_notice_stub::record($item['id'], $item); + } $oldest = $item['id']; } $this->state->messages_oldest = $oldest; @@ -395,4 +398,41 @@ class YammerRunner $qm->enqueue('YammerImport', 'yammer'); } + /** + * Record an error condition from a background run, which we should + * display in progress state for the admin. + * + * @param string $msg + */ + public function recordError($msg) + { + // HACK HACK HACK + try { + $temp = new Yammer_state(); + $temp->query('ROLLBACK'); + } catch (Exception $e) { + common_log(LOG_ERR, 'Exception while confirming rollback while recording error: ' . $e->getMessage()); + } + $old = clone($this->state); + $this->state->last_error = $msg; + $this->state->update($old); + } + + /** + * Clear the error state. + */ + public function clearError() + { + $this->recordError(''); + } + + /** + * Get the last recorded background error message, if any. + * + * @return string + */ + public function lastError() + { + return $this->state->last_error; + } } |