diff --git a/lib/Db/LocalMessageMapper.php b/lib/Db/LocalMessageMapper.php index 3196ee1a87..b6b0fb8d78 100644 --- a/lib/Db/LocalMessageMapper.php +++ b/lib/Db/LocalMessageMapper.php @@ -70,11 +70,19 @@ public function getAllForUser(string $userId, int $type = LocalMessage::TYPE_OUT $recipientMap = []; foreach ($recipients as $r) { - $recipientMap[$r->getLocalMessageId()][] = $r; + $localMessageId = $r->getLocalMessageId(); + if ($localMessageId === null) { + continue; + } + $recipientMap[$localMessageId][] = $r; } $attachmentMap = []; foreach ($attachments as $a) { - $attachmentMap[$a->getLocalMessageId()][] = $a; + $localMessageId = $a->getLocalMessageId(); + if ($localMessageId === null) { + continue; + } + $attachmentMap[$localMessageId][] = $a; } return array_map(static function ($localMessage) use ($attachmentMap, $recipientMap) { @@ -147,11 +155,19 @@ public function findDue(int $time, int $type = LocalMessage::TYPE_OUTGOING): arr $recipientMap = []; foreach ($recipients as $r) { - $recipientMap[$r->getLocalMessageId()][] = $r; + $localMessageId = $r->getLocalMessageId(); + if ($localMessageId === null) { + continue; + } + $recipientMap[$localMessageId][] = $r; } $attachmentMap = []; foreach ($attachments as $a) { - $attachmentMap[$a->getLocalMessageId()][] = $a; + $localMessageId = $a->getLocalMessageId(); + if ($localMessageId === null) { + continue; + } + $attachmentMap[$localMessageId][] = $a; } return array_map(static function ($localMessage) use ($attachmentMap, $recipientMap) { @@ -196,11 +212,19 @@ public function findDueDrafts(int $time): array { $recipientMap = []; foreach ($recipients as $r) { - $recipientMap[$r->getLocalMessageId()][] = $r; + $localMessageId = $r->getLocalMessageId(); + if ($localMessageId === null) { + continue; + } + $recipientMap[$localMessageId][] = $r; } $attachmentMap = []; foreach ($attachments as $a) { - $attachmentMap[$a->getLocalMessageId()][] = $a; + $localMessageId = $a->getLocalMessageId(); + if ($localMessageId === null) { + continue; + } + $attachmentMap[$localMessageId][] = $a; } return array_map(static function ($localMessage) use ($attachmentMap, $recipientMap) { @@ -245,7 +269,7 @@ public function updateWithRecipients(LocalMessage $message, array $to, array $cc try { $message = $this->update($message); - $this->recipientMapper->updateRecipients($message->getId(), $message->getRecipients(), $to, $cc, $bcc); + $this->recipientMapper->updateRecipients($message->getId(), $message->getRecipients() ?? [], $to, $cc, $bcc); $recipients = $this->recipientMapper->findByLocalMessageId($message->getId()); $message->setRecipients($recipients); $this->db->commit(); diff --git a/lib/Db/MessageMapper.php b/lib/Db/MessageMapper.php index 4aece97fd3..5e74225337 100644 --- a/lib/Db/MessageMapper.php +++ b/lib/Db/MessageMapper.php @@ -545,7 +545,8 @@ public function updateBulk(Account $account, bool $permflagsEnabled, Message ... */ private function updateTags(Account $account, Message $message, array $tags, PerformanceLoggerTask $perf): void { $imapTags = $message->getTags(); - $dbTags = $tags[$message->getMessageId()] ?? []; + $messageId = $message->getMessageId(); + $dbTags = $messageId !== null ? ($tags[$messageId] ?? []) : []; if ($imapTags === [] && $dbTags === []) { // neither old nor new tags @@ -1354,7 +1355,8 @@ public function findRelatedData(array $messages, string $userId): array { $tags = $this->tagMapper->getAllTagsForMessages($messages, $userId); /** @var Message $message */ $messages = array_map(static function ($message) use ($tags) { - $message->setTags($tags[$message->getMessageId()] ?? []); + $messageId = $message->getMessageId(); + $message->setTags($messageId !== null ? ($tags[$messageId] ?? []) : []); return $message; }, $messages); return $messages; diff --git a/lib/Http/JsonResponse.php b/lib/Http/JsonResponse.php index e1a0300a6b..6d3b8143de 100644 --- a/lib/Http/JsonResponse.php +++ b/lib/Http/JsonResponse.php @@ -107,7 +107,7 @@ public static function error(string $message, * @param Http::STATUS_* $status * @param array|JsonSerializable|bool|string $data * - * @return static + * @return self */ public static function errorFromThrowable(Throwable $error, int $status = Http::STATUS_INTERNAL_SERVER_ERROR,