From 9d771be8b227b33280efc88f97b19b4a5c7934b5 Mon Sep 17 00:00:00 2001 From: Bruno Da Silva Date: Thu, 17 May 2018 09:55:58 +0000 Subject: [PATCH] =?UTF-8?q?N=C2=B0955:=20fix=20the=20bugfix=20[r5766]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - handling of forbidden char code in the error message (happen for example on host error using a french windows), in this case a less verbose message is written in the table, and a issue log is written into the fs - apply for both synchronous and asynchronous SVN:trunk[5796] --- core/action.class.inc.php | 22 +++++++++++++++++----- core/asynctask.class.inc.php | 20 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/core/action.class.inc.php b/core/action.class.inc.php index bd3d29012..f6a587cfd 100644 --- a/core/action.class.inc.php +++ b/core/action.class.inc.php @@ -262,22 +262,34 @@ class ActionEmail extends ActionNotification { $sPrefix = ''; } + if ($oLog) { $oLog->Set('message', $sPrefix . $sRes); - } + $oLog->DBUpdate(); + } + } catch (Exception $e) { if ($oLog) { $oLog->Set('message', 'Error: '.$e->getMessage()); + + try + { + $oLog->DBUpdate(); + } + catch (Exception $eSecondTryUpdate) + { + IssueLog::Error("Failed to process email ".$oLog->GetKey()." - reason: ".$e->getMessage()."\nTrace:\n".$e->getTraceAsString()); + + $oLog->Set('message', 'Error: more details in the log for email "'.$oLog->GetKey().'"'); + $oLog->DBUpdate(); + } } } - if ($oLog) - { - $oLog->DBUpdate(); - } + } protected function _DoExecute($oTrigger, $aContextArgs, &$oLog) diff --git a/core/asynctask.class.inc.php b/core/asynctask.class.inc.php index cc25c1d62..0ca20d8ea 100644 --- a/core/asynctask.class.inc.php +++ b/core/asynctask.class.inc.php @@ -242,7 +242,15 @@ abstract class AsyncTask extends DBObject { $oEventLog = MetaModel::GetObject('Event', $this->Get('event_id')); $oEventLog->Set('message', "$sErrorMessage\nFailed to process async task. Remaining retries: '.$iRemaining.'. Next retry in '.$iRetryDelay.'s'"); - $oEventLog->DBUpdate(); + try + { + $oEventLog->DBUpdate(); + } + catch (Exception $e) + { + $oEventLog->Set('message', "Failed to process async task. Remaining retries: '.$iRemaining.'. Next retry in '.$iRetryDelay.'s', more details in the log"); + $oEventLog->DBUpdate(); + } } $this->Set('remaining_retries', $iRemaining - 1); $this->Set('status', 'planned'); @@ -256,7 +264,15 @@ abstract class AsyncTask extends DBObject { $oEventLog = MetaModel::GetObject('Event', $this->Get('event_id')); $oEventLog->Set('message', "$sErrorMessage\nFailed to process async task."); - $oEventLog->DBUpdate(); + try + { + $oEventLog->DBUpdate(); + } + catch (Exception $e) + { + $oEventLog->Set('message', 'Failed to process async task, more details in the log'); + $oEventLog->DBUpdate(); + } } $this->Set('status', 'error'); $this->Set('started', null);