@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.

Improve display behavior for write locks held by omnipotent users

Summary:
Ref T13614. When an omnipotent user calls "synchronizeWorkingCopyBeforeWrite()", we record a WorkingCopyVersion record with a null "userPHID". The UI then renders this as "Unknown Object (????)".

Improve this behavior:

- When no PHID is available, just render nothing in the UI (this doesn't seem meaningfully different from no version existing at all).
- Allow callers to provide an acting user PHID, similar to Editor.

There's currently no way to perform this kind of write legitimately in the upstream, but T13614 is providing one.

Test Plan:
- Wrote a script that calls "synchronizeWorkingCopyBeforeWrite()" as the omnipotent user.
- Ran script, saw "Unknown Object (????)" in the UI.
- Applied UI fix, saw empty UI.
- Applied "acting as" fix, modified script to act as the Diffusion application, ran script, saw "Diffusion" attribution in UI.

{F8814806}

Maniphest Tasks: T13614

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

+28 -8
+9 -5
src/applications/diffusion/management/DiffusionRepositoryStorageManagementPanel.php
··· 190 190 } 191 191 } 192 192 193 + $last_writer = null; 194 + $writer_epoch = null; 193 195 if ($write_properties) { 194 196 $writer_phid = idx($write_properties, 'userPHID'); 195 - $last_writer = $viewer->renderHandle($writer_phid); 197 + 198 + if ($writer_phid) { 199 + $last_writer = $viewer->renderHandle($writer_phid); 200 + } 196 201 197 202 $writer_epoch = idx($write_properties, 'epoch'); 198 - $writer_epoch = phabricator_datetime($writer_epoch, $viewer); 199 - } else { 200 - $last_writer = null; 201 - $writer_epoch = null; 203 + if ($writer_epoch) { 204 + $writer_epoch = phabricator_datetime($writer_epoch, $viewer); 205 + } 202 206 } 203 207 204 208 $rows[] = array(
+19 -3
src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php
··· 11 11 12 12 private $repository; 13 13 private $viewer; 14 + private $actingAsPHID; 14 15 private $logger; 15 16 16 17 private $clusterWriteLock; ··· 42 43 public function setLog(DiffusionRepositoryClusterEngineLogInterface $log) { 43 44 $this->logger = $log; 44 45 return $this; 46 + } 47 + 48 + public function setActingAsPHID($acting_as_phid) { 49 + $this->actingAsPHID = $acting_as_phid; 50 + return $this; 51 + } 52 + 53 + public function getActingAsPHID() { 54 + return $this->actingAsPHID; 55 + } 56 + 57 + private function getEffectiveActingAsPHID() { 58 + if ($this->actingAsPHID) { 59 + return $this->actingAsPHID; 60 + } 61 + 62 + return $this->getViewer()->getPHID(); 45 63 } 46 64 47 65 ··· 402 420 $repository_phid, 403 421 $device_phid, 404 422 array( 405 - 'userPHID' => $viewer->getPHID(), 423 + 'userPHID' => $this->getEffectiveActingAsPHID(), 406 424 'epoch' => PhabricatorTime::getNow(), 407 425 'devicePHID' => $device_phid, 408 426 ), ··· 432 450 if ($repository->isHosted()) { 433 451 return; 434 452 } 435 - 436 - $viewer = $this->getViewer(); 437 453 438 454 $device = AlmanacKeys::getLiveDevice(); 439 455 $device_phid = $device->getPHID();