Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions lib/Db/LocalMessageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions lib/Db/MessageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Http/JsonResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading