1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-21 22:32:41 +01:00

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
This commit is contained in:
epriestley 2021-06-01 06:08:07 -07:00
parent a8f429cdbf
commit bdda7eed07
2 changed files with 28 additions and 8 deletions

View file

@ -190,15 +190,19 @@ final class DiffusionRepositoryStorageManagementPanel
}
}
$last_writer = null;
$writer_epoch = null;
if ($write_properties) {
$writer_phid = idx($write_properties, 'userPHID');
$last_writer = $viewer->renderHandle($writer_phid);
if ($writer_phid) {
$last_writer = $viewer->renderHandle($writer_phid);
}
$writer_epoch = idx($write_properties, 'epoch');
$writer_epoch = phabricator_datetime($writer_epoch, $viewer);
} else {
$last_writer = null;
$writer_epoch = null;
if ($writer_epoch) {
$writer_epoch = phabricator_datetime($writer_epoch, $viewer);
}
}
$rows[] = array(

View file

@ -11,6 +11,7 @@ final class DiffusionRepositoryClusterEngine extends Phobject {
private $repository;
private $viewer;
private $actingAsPHID;
private $logger;
private $clusterWriteLock;
@ -44,6 +45,23 @@ final class DiffusionRepositoryClusterEngine extends Phobject {
return $this;
}
public function setActingAsPHID($acting_as_phid) {
$this->actingAsPHID = $acting_as_phid;
return $this;
}
public function getActingAsPHID() {
return $this->actingAsPHID;
}
private function getEffectiveActingAsPHID() {
if ($this->actingAsPHID) {
return $this->actingAsPHID;
}
return $this->getViewer()->getPHID();
}
/* -( Cluster Synchronization )-------------------------------------------- */
@ -402,7 +420,7 @@ final class DiffusionRepositoryClusterEngine extends Phobject {
$repository_phid,
$device_phid,
array(
'userPHID' => $viewer->getPHID(),
'userPHID' => $this->getEffectiveActingAsPHID(),
'epoch' => PhabricatorTime::getNow(),
'devicePHID' => $device_phid,
),
@ -433,8 +451,6 @@ final class DiffusionRepositoryClusterEngine extends Phobject {
return;
}
$viewer = $this->getViewer();
$device = AlmanacKeys::getLiveDevice();
$device_phid = $device->getPHID();