ticket system improved logging on invalid date

This commit is contained in:
OpenXE 2023-04-17 18:21:43 +02:00
parent 50df55e35e
commit f0a24b7e5b
2 changed files with 15 additions and 8 deletions

View File

@ -309,6 +309,7 @@ final class MailMessageData implements MailMessageInterface, JsonSerializable
}
$dateTime = date_create($date->getValue());
if ($dateTime === false) {
throw new InvalidArgumentException('Invalid date: '.$date->getValue());
return null;
}

View File

@ -511,7 +511,10 @@ class TicketImportHelper
continue;
}
} catch (Throwable $e) {
$this->logger->error('Error during email import '.$messageNumber, ['message' => substr(print_r($message,true),0,1000)]);
$exception_message = $e->getMessage();
$this->logger->error('Error during email import '.$messageNumber, ['exc-message' => $exception_message ,'message2' => substr(print_r($message,true),0,1000)]);
continue;
}
}
@ -573,14 +576,17 @@ class TicketImportHelper
$this->logger->debug('Text (converted)',['plain' => $action, 'html' => $action_html]);
// Import database emailbackup
$date = $message->getDate();
if (is_null($date)) { // This should not be happening -> Todo check getDate function
$this->logger->debug('Null date',['subject' => $message->getSubject(), $message->getHeader('date')->getValue()]);
return(false);
} else {
$timestamp = $date->getTimestamp();
$frommd5 = md5($from . $subject . $timestamp);
try {
$date = $message->getDate();
}
catch (exception $e) {
$this->logger->debug('Invalid date',['exc-message' => $e->getMessage(),'subject' => $message->getSubject(), $message->getHeader('date')->getValue()]);
return(false);
}
$timestamp = $date->getTimestamp();
$frommd5 = md5($from . $subject . $timestamp);
$empfang = $date->format('Y-m-d H:i:s');
$sql = "SELECT COUNT(id)
FROM `emailbackup_mails`