diff --git a/lib/Db/LocalMessageMapper.php b/lib/Db/LocalMessageMapper.php index 06ef03d023..0be085ce63 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) { @@ -134,11 +142,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) { @@ -183,11 +199,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) { @@ -232,7 +256,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 ce29c480ed..3a4e253207 100644 --- a/lib/Db/MessageMapper.php +++ b/lib/Db/MessageMapper.php @@ -531,7 +531,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 @@ -1340,7 +1341,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,