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()); $dateTime = date_create($date->getValue());
if ($dateTime === false) { if ($dateTime === false) {
throw new InvalidArgumentException('Invalid date: '.$date->getValue());
return null; return null;
} }

View File

@ -511,7 +511,10 @@ class TicketImportHelper
continue; continue;
} }
} catch (Throwable $e) { } 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; continue;
} }
} }
@ -573,14 +576,17 @@ class TicketImportHelper
$this->logger->debug('Text (converted)',['plain' => $action, 'html' => $action_html]); $this->logger->debug('Text (converted)',['plain' => $action, 'html' => $action_html]);
// Import database emailbackup // Import database emailbackup
try {
$date = $message->getDate(); $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()]); catch (exception $e) {
$this->logger->debug('Invalid date',['exc-message' => $e->getMessage(),'subject' => $message->getSubject(), $message->getHeader('date')->getValue()]);
return(false); return(false);
} else { }
$timestamp = $date->getTimestamp(); $timestamp = $date->getTimestamp();
$frommd5 = md5($from . $subject . $timestamp); $frommd5 = md5($from . $subject . $timestamp);
}
$empfang = $date->format('Y-m-d H:i:s'); $empfang = $date->format('Y-m-d H:i:s');
$sql = "SELECT COUNT(id) $sql = "SELECT COUNT(id)
FROM `emailbackup_mails` FROM `emailbackup_mails`