diff --git a/src/applications/diffusion/management/DiffusionRepositoryStorageManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryStorageManagementPanel.php index f657a81641..2b92c73c97 100644 --- a/src/applications/diffusion/management/DiffusionRepositoryStorageManagementPanel.php +++ b/src/applications/diffusion/management/DiffusionRepositoryStorageManagementPanel.php @@ -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( diff --git a/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php b/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php index 9df37c7fb5..a364828397 100644 --- a/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php +++ b/src/applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php @@ -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();