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

Link to Harbormaster build targets from the Daemon worker page

Summary:
Fixes T7370. Two changes:

- Make the default to show nothing, instead of showing all the data. This is a better default because the data is sometimes sensitive. Workers should have to opt in to revealing it.
- For TargetWorkers, link to the target (technically the build, for now, since there's no dedicated target detail page).

Test Plan: {F698325}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7370

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

+52 -27
+3 -3
src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php
··· 149 149 $worker = $task->getWorkerInstance(); 150 150 $data = $worker->renderForDisplay($viewer); 151 151 152 - $view->addProperty( 153 - pht('Data'), 154 - $data); 152 + if ($data !== null) { 153 + $view->addProperty(pht('Data'), $data); 154 + } 155 155 156 156 return $view; 157 157 }
+5 -6
src/applications/harbormaster/phid/HarbormasterBuildPHIDType.php
··· 27 27 28 28 foreach ($handles as $phid => $handle) { 29 29 $build = $objects[$phid]; 30 - $handles[$phid]->setName(pht( 31 - 'Build %d: %s', 32 - $build->getID(), 33 - $build->getName())); 34 - $handles[$phid]->setURI( 35 - '/harbormaster/build/'.$build->getID()); 30 + $build_id = $build->getID(); 31 + $name = $build->getName(); 32 + 33 + $handle->setName(pht('Build %d: %s', $build_id, $name)); 34 + $handle->setURI("/harbormaster/build/{$build_id}/"); 36 35 } 37 36 } 38 37
+11 -1
src/applications/harbormaster/phid/HarbormasterBuildTargetPHIDType.php
··· 26 26 array $objects) { 27 27 28 28 foreach ($handles as $phid => $handle) { 29 - $build_target = $objects[$phid]; 29 + $target = $objects[$phid]; 30 + $target_id = $target->getID(); 31 + 32 + // Build target don't currently have their own page, so just point 33 + // the user at the build until we have one. 34 + $build = $target->getBuild(); 35 + $build_id = $build->getID(); 36 + $uri = "/harbormaster/build/{$build_id}/"; 37 + 38 + $handle->setName(pht('Build Target %d', $target_id)); 39 + $handle->setURI($uri); 30 40 } 31 41 } 32 42
+22 -5
src/applications/harbormaster/worker/HarbormasterBuildWorker.php
··· 5 5 */ 6 6 final class HarbormasterBuildWorker extends HarbormasterWorker { 7 7 8 + public function renderForDisplay(PhabricatorUser $viewer) { 9 + try { 10 + $build = $this->loadBuild(); 11 + } catch (Exception $ex) { 12 + return null; 13 + } 14 + 15 + return $viewer->renderHandle($build->getPHID()); 16 + } 17 + 8 18 protected function doWork() { 19 + $viewer = $this->getViewer(); 20 + $build = $this->loadBuild(); 21 + 22 + id(new HarbormasterBuildEngine()) 23 + ->setViewer($viewer) 24 + ->setBuild($build) 25 + ->continueBuild(); 26 + } 27 + 28 + private function loadBuild() { 9 29 $data = $this->getTaskData(); 10 30 $id = idx($data, 'buildID'); 31 + 11 32 $viewer = $this->getViewer(); 12 - 13 33 $build = id(new HarbormasterBuildQuery()) 14 34 ->setViewer($viewer) 15 35 ->withIDs(array($id)) ··· 19 39 pht('Invalid build ID "%s".', $id)); 20 40 } 21 41 22 - id(new HarbormasterBuildEngine()) 23 - ->setViewer($viewer) 24 - ->setBuild($build) 25 - ->continueBuild(); 42 + return $build; 26 43 } 27 44 28 45 }
+10
src/applications/harbormaster/worker/HarbormasterTargetWorker.php
··· 11 11 return phutil_units('24 hours in seconds'); 12 12 } 13 13 14 + public function renderForDisplay(PhabricatorUser $viewer) { 15 + try { 16 + $target = $this->loadBuildTarget(); 17 + } catch (Exception $ex) { 18 + return null; 19 + } 20 + 21 + return $viewer->renderHandle($target->getPHID()); 22 + } 23 + 14 24 private function loadBuildTarget() { 15 25 $data = $this->getTaskData(); 16 26 $id = idx($data, 'targetID');
-5
src/applications/repository/worker/PhabricatorRepositoryPushMailWorker.php
··· 130 130 return $target->willSendMail($mail); 131 131 } 132 132 133 - public function renderForDisplay(PhabricatorUser $viewer) { 134 - // This data has some sensitive stuff, so don't show it. 135 - return null; 136 - } 137 - 138 133 private function renderRefs(array $logs) { 139 134 $ref_lines = array(); 140 135 $ref_list = array();
+1 -2
src/infrastructure/daemon/workers/PhabricatorWorker.php
··· 210 210 } 211 211 212 212 public function renderForDisplay(PhabricatorUser $viewer) { 213 - $data = PhutilReadableSerializer::printableValue($this->data); 214 - return phutil_tag('pre', array(), $data); 213 + return null; 215 214 } 216 215 217 216 /**
-5
src/infrastructure/sms/worker/PhabricatorSMSWorker.php
··· 3 3 abstract class PhabricatorSMSWorker 4 4 extends PhabricatorWorker { 5 5 6 - public function renderForDisplay(PhabricatorUser $viewer) { 7 - // This data has some sensitive stuff, so don't show it. 8 - return null; 9 - } 10 - 11 6 }