From 686848a0ae85782376d835c33b73c9b533abc511 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Mon, 30 Jun 2014 15:24:49 +0000 Subject: [PATCH] #953 Protect the background processing against corrupted (incomplete) objects. SVN:trunk[3231] --- core/asynctask.class.inc.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core/asynctask.class.inc.php b/core/asynctask.class.inc.php index f2e4d468a..d60c3268c 100644 --- a/core/asynctask.class.inc.php +++ b/core/asynctask.class.inc.php @@ -40,8 +40,24 @@ class ExecAsyncTask implements iBackgroundProcess $iProcessed = 0; while ((time() < $iTimeLimit) && ($oTask = $oSet->Fetch())) { - $oTask->Set('started', time()); - $oTask->DBUpdate(); + try + { + $oTask->Set('started', time()); + $oTask->DBUpdate(); + } + catch(Exception $e) + { + // Corrupted task !! (for example: "Failed to reload object") + IssueLog::Error('Failed to process async task #'.$oTask->GetKey().' - reason: '.$e->getMessage().' - fatal error, deleting the task.'); + if ($oTask->Get('event_id') != 0) + { + $oEventLog = MetaModel::GetObject('Event', $oTask->Get('event_id')); + $oEventLog->Set('message', 'Failed, corrupted data: '.$e->getMessage()); + $oEventLog->DBUpdate(); + } + $oTask->DBDelete(); + continue; // end of processing for this task + } try {