From 8507d3a95072db363add43d8a397dfd502c3db37 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Thu, 9 Nov 2023 21:04:06 +0100 Subject: [PATCH] Fix Exception in Chat room when you are not a Participant Summary: After this change you can lurk in public chats, and receive notifications, without crashing your planet. Fix exception "Undefined index: PHID-USER-..." shown to newcomers when they are receiving messages from a public Chat they are not members of. Closes T15497 Test Plan: - Have the Notification server (Aphlict) enabled and running. https://we.phorge.it/book/phorge/article/notifications/ - Be user Alice and visit a Conpherence Room. Alice must be not a participant. - Be user Bob and send a message in that Room. Now Alice does not see a crash anymore, but the message from Bob. Reviewers: O1 Blessed Committers, speck Reviewed By: O1 Blessed Committers, speck Subscribers: speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15497 Differential Revision: https://we.phorge.it/D25408 --- .../controller/ConpherenceUpdateController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php index a792a5a4d4..6d838e72bc 100644 --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -328,7 +328,12 @@ final class ConpherenceUpdateController ->executeOne(); $non_update = false; - $participant = $conpherence->getParticipant($user->getPHID()); + + // The User is always available. The Participant may not. See: + // User: it's you, lurking the Chat (maybe it's a public chat). + // Participant: it's you, if you are a Chat Member. + // https://we.phorge.it/T15497 + $participant = $conpherence->getParticipantIfExists($user->getPHID()); if ($need_transactions && $conpherence->getTransactions()) { $data = ConpherenceTransactionRenderer::renderTransactions( @@ -336,7 +341,7 @@ final class ConpherenceUpdateController $conpherence); $key = PhabricatorConpherenceColumnMinimizeSetting::SETTINGKEY; $minimized = $user->getUserSetting($key); - if (!$minimized) { + if (!$minimized && $participant) { $participant->markUpToDate($conpherence); } } else if ($need_transactions) {