diff --git a/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php b/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php index 97242969b0..70eb3c78d3 100644 --- a/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php +++ b/src/applications/daemon/controller/PhabricatorDaemonConsoleController.php @@ -73,6 +73,7 @@ final class PhabricatorDaemonConsoleController $logs = id(new PhabricatorDaemonLogQuery()) ->setViewer($user) ->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE) + ->setAllowStatusWrites(true) ->execute(); $taskmasters = 0; diff --git a/src/applications/daemon/controller/PhabricatorDaemonLogListController.php b/src/applications/daemon/controller/PhabricatorDaemonLogListController.php index e97220a243..0e5552dcf7 100644 --- a/src/applications/daemon/controller/PhabricatorDaemonLogListController.php +++ b/src/applications/daemon/controller/PhabricatorDaemonLogListController.php @@ -12,6 +12,7 @@ final class PhabricatorDaemonLogListController $logs = id(new PhabricatorDaemonLogQuery()) ->setViewer($viewer) + ->setAllowStatusWrites(true) ->executeWithCursorPager($pager); $daemon_table = new PhabricatorDaemonLogListView(); diff --git a/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php b/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php index 5116c46223..9da72ceb01 100644 --- a/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php +++ b/src/applications/daemon/controller/PhabricatorDaemonLogViewController.php @@ -16,6 +16,7 @@ final class PhabricatorDaemonLogViewController $log = id(new PhabricatorDaemonLogQuery()) ->setViewer($user) ->withIDs(array($this->id)) + ->setAllowStatusWrites(true) ->executeOne(); if (!$log) { return new Aphront404Response(); diff --git a/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php b/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php index 8613ef6de4..4c65c74e8f 100644 --- a/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php +++ b/src/applications/daemon/management/PhabricatorDaemonManagementLogWorkflow.php @@ -34,6 +34,7 @@ final class PhabricatorDaemonManagementLogWorkflow $daemon = id(new PhabricatorDaemonLogQuery()) ->setViewer($this->getViewer()) ->withIDs(array($id)) + ->setAllowStatusWrites(true) ->executeOne(); if (!$daemon) { diff --git a/src/applications/daemon/query/PhabricatorDaemonLogQuery.php b/src/applications/daemon/query/PhabricatorDaemonLogQuery.php index 656edd7bdc..c3f2ddf7f0 100644 --- a/src/applications/daemon/query/PhabricatorDaemonLogQuery.php +++ b/src/applications/daemon/query/PhabricatorDaemonLogQuery.php @@ -9,6 +9,7 @@ final class PhabricatorDaemonLogQuery private $ids; private $status = self::STATUS_ALL; private $daemonClasses; + private $allowStatusWrites; public static function getTimeUntilUnknown() { return 3 * PhutilDaemonOverseer::HEARTBEAT_WAIT; @@ -33,6 +34,11 @@ final class PhabricatorDaemonLogQuery return $this; } + public function setAllowStatusWrites($allow) { + $this->allowStatusWrites = $allow; + return $this; + } + public function loadPage() { $table = new PhabricatorDaemonLog(); $conn_r = $table->establishConnection('r'); @@ -80,11 +86,16 @@ final class PhabricatorDaemonLogQuery $status = $status_dead; } - // If we changed the daemon's status, update it. + // If we changed the daemon's status, adjust it. if ($status != $daemon->getStatus()) { - $guard = AphrontWriteGuard::beginScopedUnguardedWrites(); - $daemon->setStatus($status)->save(); - unset($guard); + $daemon->setStatus($status); + + // ...and write it, if we're in a context where that's reasonable. + if ($this->allowStatusWrites) { + $guard = AphrontWriteGuard::beginScopedUnguardedWrites(); + $daemon->save(); + unset($guard); + } } // If the daemon no longer matches the filter, get rid of it.