From aa098e598f83a04ae8e9ec27a0df96b17b9c17c8 Mon Sep 17 00:00:00 2001 From: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com> Date: Mon, 2 Nov 2026 16:54:26 +0100 Subject: [PATCH] fix(psalm): resolve remaining type issues flagged by Psalm 7 Follow-up to #13932 and #13933: re-ran the open Psalm v7 bump (#13243) after both of those merged to see what was left. Two things slipped through the first two batches. - The three FeatureExtraction classes each had a second array access (flaggedMessages/readMessages/repliedMessages) using the same possibly-null $email key as the one already suppressed; only the first access per file got a suppression comment. - MessageMapper (Db) had a second, different possibly-null argument: $recipient->getLabel() passed into mb_strcut() when building recipient rows. Address's own fromRaw() already treats "no label" as "fall back to the email", so this does the same instead of suppressing. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: Christoph Wurst <1374172+ChristophWurst@users.noreply.github.com> --- lib/Db/MessageMapper.php | 7 ++++--- .../FeatureExtraction/ImportantMessagesExtractor.php | 1 + .../FeatureExtraction/ReadMessagesExtractor.php | 1 + .../FeatureExtraction/RepliedMessagesExtractor.php | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Db/MessageMapper.php b/lib/Db/MessageMapper.php index 70c52627f8..bd9d996c18 100644 --- a/lib/Db/MessageMapper.php +++ b/lib/Db/MessageMapper.php @@ -338,15 +338,16 @@ public function insertBulk(Account $account, Message ...$messages): void { ]; foreach ($recipientTypes as $type => $recipients) { foreach ($recipients->iterate() as $recipient) { - if ($recipient->getEmail() === null) { + $recipientEmail = $recipient->getEmail(); + if ($recipientEmail === null) { // If for some reason the e-mail is not set we should ignore this entry continue; } $qb2->setParameter('message_id', $message->getId(), IQueryBuilder::PARAM_INT); $qb2->setParameter('type', $type, IQueryBuilder::PARAM_INT); - $qb2->setParameter('label', mb_strcut($recipient->getLabel(), 0, 255), IQueryBuilder::PARAM_STR); - $qb2->setParameter('email', mb_strcut($recipient->getEmail(), 0, 255), IQueryBuilder::PARAM_STR); + $qb2->setParameter('label', mb_strcut($recipient->getLabel() ?? $recipientEmail, 0, 255), IQueryBuilder::PARAM_STR); + $qb2->setParameter('email', mb_strcut($recipientEmail, 0, 255), IQueryBuilder::PARAM_STR); $qb2->executeStatement(); } diff --git a/lib/Service/Classification/FeatureExtraction/ImportantMessagesExtractor.php b/lib/Service/Classification/FeatureExtraction/ImportantMessagesExtractor.php index aeb4151895..6f93a2ce0a 100644 --- a/lib/Service/Classification/FeatureExtraction/ImportantMessagesExtractor.php +++ b/lib/Service/Classification/FeatureExtraction/ImportantMessagesExtractor.php @@ -52,6 +52,7 @@ public function extract(Message $message): array { // Prevent div by 0 return [0]; } + /** @psalm-suppress PossiblyNullArrayOffset */ return [($this->flaggedMessages[$email] ?? 0) / $total]; } } diff --git a/lib/Service/Classification/FeatureExtraction/ReadMessagesExtractor.php b/lib/Service/Classification/FeatureExtraction/ReadMessagesExtractor.php index 022230a861..67cfa2ac57 100644 --- a/lib/Service/Classification/FeatureExtraction/ReadMessagesExtractor.php +++ b/lib/Service/Classification/FeatureExtraction/ReadMessagesExtractor.php @@ -56,6 +56,7 @@ public function extract(Message $message): array { return [0]; } + /** @psalm-suppress PossiblyNullArrayOffset */ return [($this->readMessages[$email] ?? 0) / $total]; } } diff --git a/lib/Service/Classification/FeatureExtraction/RepliedMessagesExtractor.php b/lib/Service/Classification/FeatureExtraction/RepliedMessagesExtractor.php index f242420bb5..cdd1a46d15 100644 --- a/lib/Service/Classification/FeatureExtraction/RepliedMessagesExtractor.php +++ b/lib/Service/Classification/FeatureExtraction/RepliedMessagesExtractor.php @@ -56,6 +56,7 @@ public function extract(Message $message): array { return [0]; } + /** @psalm-suppress PossiblyNullArrayOffset */ return [($this->repliedMessages[$email] ?? 0) / $total]; } }