@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix three minor edge case behaviors in Conpherence

Summary:
Couple of tweaks:

- If a conpherence has no participants, we fail to `attachParticipants()`. This can happen if you leave a Conpherence as the last participant, then visit the URI again explicitly.
- If you can't load any transactions (usually, because you don't have permission to view a thread's transactions), we try to attach `null` instead of `array()`. This can happen if you attempt to view a thread you don't have permission to see. A more general fix would be to tweak the load/filtering order, but I'm leaving that for another time since it's more involved and only gives us a small performance gain in unusual sitautions.
- `initializeNewThread()` should be declared `static`.

Test Plan:
- Viewed a thread with no participants, got proper policy error.
- Viewed a thread I couldn't see, got proper policy error.
- Grepped for `initializeNewThread()`.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D8467

+13 -5
+12 -4
src/applications/conpherence/query/ConpherenceThreadQuery.php
··· 129 129 $participants = id(new ConpherenceParticipant()) 130 130 ->loadAllWhere('conpherencePHID IN (%Ls)', array_keys($conpherences)); 131 131 $map = mgroup($participants, 'getConpherencePHID'); 132 - foreach ($map as $conpherence_phid => $conpherence_participants) { 133 - $current_conpherence = $conpherences[$conpherence_phid]; 132 + 133 + foreach ($conpherences as $current_conpherence) { 134 + $conpherence_phid = $current_conpherence->getPHID(); 135 + 136 + $conpherence_participants = idx( 137 + $map, 138 + $conpherence_phid, 139 + array()); 140 + 134 141 $conpherence_participants = mpull( 135 142 $conpherence_participants, 136 143 null, 137 144 'getParticipantPHID'); 145 + 138 146 $current_conpherence->attachParticipants($conpherence_participants); 139 147 $current_conpherence->attachHandles(array()); 140 148 } ··· 183 191 $transactions = $query->execute(); 184 192 $transactions = mgroup($transactions, 'getObjectPHID'); 185 193 foreach ($conpherences as $phid => $conpherence) { 186 - $current_transactions = $transactions[$phid]; 194 + $current_transactions = idx($transactions, $phid, array()); 187 195 $handles = array(); 188 196 foreach ($current_transactions as $transaction) { 189 197 $handles += $transaction->getHandles(); 190 198 } 191 199 $conpherence->attachHandles($conpherence->getHandles() + $handles); 192 - $conpherence->attachTransactions($transactions[$phid]); 200 + $conpherence->attachTransactions($current_transactions); 193 201 } 194 202 return $this; 195 203 }
+1 -1
src/applications/conpherence/storage/ConpherenceThread.php
··· 18 18 private $widgetData = self::ATTACHABLE; 19 19 private $images = array(); 20 20 21 - public function initializeNewThread(PhabricatorUser $sender) { 21 + public static function initializeNewThread(PhabricatorUser $sender) { 22 22 return id(new ConpherenceThread()) 23 23 ->setMessageCount(0) 24 24 ->setTitle('');