Commit d736fd6c0c99cb998af56979b12ceab60ed101ee

  • avatar
  • Francois Marier <francois @cata…st.net.nz>
  • Mon Jun 14 05:41:01 CEST 2010
Remove activities from the queue before they are handled

This change means that if the handler fails, this activity will
never be handled properly, which is unfortunate.

However, it also means that if an email gets sent before a failure
happens (DB rollback, PHP exception, segfault, memory exhaustion)
it will not get sent over and over again.

Signed-off-by: Francois Marier <francois@catalyst.net.nz>
  
193193 $watchlist = activity_locate_typerecord('watchlist');
194194 $viewsnotified = array();
195195 foreach ($toprocess as $activity) {
196 // Remove this activity from the queue to make sure we
197 // never send duplicate emails even if part of the
198 // activity handler fails for whatever reason
199 if (!delete_records('activity_queue', 'id', $activity->id)) {
200 log_warn("Unable to remove activity $activity->id from the queue. Skipping it.");
201 continue;
202 }
203
196204 $data = unserialize($activity->data);
197205 if ($activity->type == $watchlist->id && !empty($data->view)) {
198206 if (isset($viewsnotified[$data->view])) {
220220 }
221221 db_commit();
222222 }
223 delete_records('activity_queue');
224223 }
225224}
226225