Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / diffusion / ssh / DiffusionGitUploadPackSSHWorkflow.php
blob57c43b5a126f5c718ec7ed81abd3a698f3fc6051
1 <?php
3 final class DiffusionGitUploadPackSSHWorkflow
4 extends DiffusionGitSSHWorkflow {
6 protected function didConstruct() {
7 $this->setName('git-upload-pack');
8 $this->setArguments(
9 array(
10 array(
11 'name' => 'dir',
12 'wildcard' => true,
14 ));
17 protected function executeRepositoryOperations() {
18 $is_proxy = $this->shouldProxy();
19 if ($is_proxy) {
20 return $this->executeRepositoryProxyOperations($for_write = false);
23 $viewer = $this->getSSHUser();
24 $repository = $this->getRepository();
25 $device = AlmanacKeys::getLiveDevice();
27 $skip_sync = $this->shouldSkipReadSynchronization();
29 $command = csprintf('git-upload-pack -- %s', $repository->getLocalPath());
30 if (!$skip_sync) {
31 $cluster_engine = id(new DiffusionRepositoryClusterEngine())
32 ->setViewer($viewer)
33 ->setRepository($repository)
34 ->setLog($this)
35 ->synchronizeWorkingCopyBeforeRead();
37 if ($device) {
38 $this->writeClusterEngineLogMessage(
39 pht(
40 "# Cleared to fetch on cluster host \"%s\".\n",
41 $device->getName()));
45 $command = PhabricatorDaemon::sudoCommandAsDaemonUser($command);
47 $pull_event = $this->newPullEvent();
49 $future = id(new ExecFuture('%C', $command))
50 ->setEnv($this->getEnvironment());
52 $log = $this->newProtocolLog($is_proxy);
53 if ($log) {
54 $this->setProtocolLog($log);
55 $log->didStartSession($command);
58 if (PhabricatorEnv::getEnvConfig('phabricator.show-prototypes')) {
59 $protocol = new DiffusionGitUploadPackWireProtocol();
60 if ($log) {
61 $protocol->setProtocolLog($log);
63 $this->setWireProtocol($protocol);
66 $err = $this->newPassthruCommand()
67 ->setIOChannel($this->getIOChannel())
68 ->setCommandChannelFromExecFuture($future)
69 ->execute();
71 if ($log) {
72 $log->didEndSession();
75 if ($err) {
76 $pull_event
77 ->setResultType(PhabricatorRepositoryPullEvent::RESULT_ERROR)
78 ->setResultCode($err);
79 } else {
80 $pull_event
81 ->setResultType(PhabricatorRepositoryPullEvent::RESULT_PULL)
82 ->setResultCode(0);
85 $pull_event->save();
87 if (!$err) {
88 $this->waitForGitClient();
91 return $err;