diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-07-01 12:10:25 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-07-01 12:10:25 -0400 |
commit | a35138b2684ec5275a1ffd7badfe7826cf2173b1 (patch) | |
tree | caebfb727b3770108505e722ce534db56b776e69 /lib/dbqueuemanager.php | |
parent | 2325d934a8abfc611f455d4f0b816e2dd62c5ec4 (diff) |
add fail() method to dbqueuemanager and fix logging
Diffstat (limited to 'lib/dbqueuemanager.php')
-rw-r--r-- | lib/dbqueuemanager.php | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/lib/dbqueuemanager.php b/lib/dbqueuemanager.php index 46be54b30..c9e5ef243 100644 --- a/lib/dbqueuemanager.php +++ b/lib/dbqueuemanager.php @@ -84,10 +84,10 @@ class DBQueueManager extends QueueManager 'transport' => $queue)); if (empty($qi)) { - $this->log(LOG_INFO, 'Cannot find queue item for notice '.$notice->id.', queue '.$queue); + $this->_log(LOG_INFO, 'Cannot find queue item for notice '.$notice->id.', queue '.$queue); } else { if (empty($qi->claimed)) { - $this->log(LOG_WARNING, 'Reluctantly releasing unclaimed queue item '. + $this->_log(LOG_WARNING, 'Reluctantly releasing unclaimed queue item '. 'for '.$notice->id.', queue '.$queue); } $qi->delete(); @@ -95,7 +95,36 @@ class DBQueueManager extends QueueManager $qi = null; } - $this->log(LOG_INFO, 'done with notice ID = ' . $notice->id); + $this->_log(LOG_INFO, 'done with notice ID = ' . $notice->id); + + $notice->free(); + $notice = null; + } + + function fail($object, $queue) + { + // XXX: right now, we only handle notices + + $notice = $object; + + $qi = Queue_item::pkeyGet(array('notice_id' => $notice->id, + 'transport' => $queue)); + + if (empty($qi)) { + $this->_log(LOG_INFO, 'Cannot find queue item for notice '.$notice->id.', queue '.$queue); + } else { + if (empty($qi->claimed)) { + $this->_log(LOG_WARNING, 'Ignoring failure for unclaimed queue item '. + 'for '.$notice->id.', queue '.$queue); + } else { + $orig = clone($qi); + $qi->claimed = null; + $qi->update($orig); + $qi = null; + } + } + + $this->_log(LOG_INFO, 'done with notice ID = ' . $notice->id); $notice->free(); $notice = null; |