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

Give HarbormasterBuildUnitMessage a real Query class

Summary: Ref T13088. Prepares for putting test names in a separate table to release the 255-character limit.

Test Plan: Viewed revisions, buildables, builds, test lists, specific tests.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13088

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

+119 -19
+6 -1
src/__phutil_library_map__.php
··· 1365 1365 'HarbormasterBuildTransactionEditor' => 'applications/harbormaster/editor/HarbormasterBuildTransactionEditor.php', 1366 1366 'HarbormasterBuildTransactionQuery' => 'applications/harbormaster/query/HarbormasterBuildTransactionQuery.php', 1367 1367 'HarbormasterBuildUnitMessage' => 'applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php', 1368 + 'HarbormasterBuildUnitMessageQuery' => 'applications/harbormaster/query/HarbormasterBuildUnitMessageQuery.php', 1368 1369 'HarbormasterBuildViewController' => 'applications/harbormaster/controller/HarbormasterBuildViewController.php', 1369 1370 'HarbormasterBuildWorker' => 'applications/harbormaster/worker/HarbormasterBuildWorker.php', 1370 1371 'HarbormasterBuildable' => 'applications/harbormaster/storage/HarbormasterBuildable.php', ··· 6983 6984 'HarbormasterBuildTransaction' => 'PhabricatorApplicationTransaction', 6984 6985 'HarbormasterBuildTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 6985 6986 'HarbormasterBuildTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 6986 - 'HarbormasterBuildUnitMessage' => 'HarbormasterDAO', 6987 + 'HarbormasterBuildUnitMessage' => array( 6988 + 'HarbormasterDAO', 6989 + 'PhabricatorPolicyInterface', 6990 + ), 6991 + 'HarbormasterBuildUnitMessageQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6987 6992 'HarbormasterBuildViewController' => 'HarbormasterController', 6988 6993 'HarbormasterBuildWorker' => 'HarbormasterWorker', 6989 6994 'HarbormasterBuildable' => array(
+6 -4
src/applications/differential/controller/DifferentialChangesetViewController.php
··· 420 420 } 421 421 422 422 private function loadCoverage(DifferentialChangeset $changeset) { 423 + $viewer = $this->getViewer(); 424 + 423 425 $target_phids = $changeset->getDiff()->getBuildTargetPHIDs(); 424 426 if (!$target_phids) { 425 427 return null; 426 428 } 427 429 428 - $unit = id(new HarbormasterBuildUnitMessage())->loadAllWhere( 429 - 'buildTargetPHID IN (%Ls)', 430 - $target_phids); 431 - 430 + $unit = id(new HarbormasterBuildUnitMessageQuery()) 431 + ->setViewer($viewer) 432 + ->withBuildTargetPHIDs($target_phids) 433 + ->execute(); 432 434 if (!$unit) { 433 435 return null; 434 436 }
+4 -3
src/applications/differential/controller/DifferentialController.php
··· 192 192 $all_target_phids = array_mergev($target_map); 193 193 194 194 if ($all_target_phids) { 195 - $unit_messages = id(new HarbormasterBuildUnitMessage())->loadAllWhere( 196 - 'buildTargetPHID IN (%Ls)', 197 - $all_target_phids); 195 + $unit_messages = id(new HarbormasterBuildUnitMessageQuery()) 196 + ->setViewer($viewer) 197 + ->withBuildTargetPHIDs($all_target_phids) 198 + ->execute(); 198 199 $unit_messages = mgroup($unit_messages, 'getBuildTargetPHID'); 199 200 } else { 200 201 $unit_messages = array();
+4 -3
src/applications/differential/storage/DifferentialDiff.php
··· 387 387 return array(); 388 388 } 389 389 390 - $unit = id(new HarbormasterBuildUnitMessage())->loadAllWhere( 391 - 'buildTargetPHID IN (%Ls)', 392 - $target_phids); 390 + $unit = id(new HarbormasterBuildUnitMessageQuery()) 391 + ->setViewer($viewer) 392 + ->withBuildTargetPHIDs($target_phids) 393 + ->execute(); 393 394 394 395 $map = array(); 395 396 foreach ($unit as $message) {
+4 -3
src/applications/harbormaster/controller/HarbormasterBuildableViewController.php
··· 312 312 'buildTargetPHID IN (%Ls)', 313 313 $target_phids); 314 314 315 - $unit_data = id(new HarbormasterBuildUnitMessage())->loadAllWhere( 316 - 'buildTargetPHID IN (%Ls)', 317 - $target_phids); 315 + $unit_data = id(new HarbormasterBuildUnitMessageQuery()) 316 + ->setViewer($viewer) 317 + ->withBuildTargetPHIDs($target_phids) 318 + ->execute(); 318 319 319 320 if ($lint_data) { 320 321 $lint_table = id(new HarbormasterLintPropertyView())
+4 -3
src/applications/harbormaster/controller/HarbormasterUnitMessageListController.php
··· 31 31 32 32 $unit_data = array(); 33 33 if ($target_phids) { 34 - $unit_data = id(new HarbormasterBuildUnitMessage())->loadAllWhere( 35 - 'buildTargetPHID IN (%Ls)', 36 - $target_phids); 34 + $unit_data = id(new HarbormasterBuildUnitMessageQuery()) 35 + ->setViewer($viewer) 36 + ->withBuildTargetPHIDs($target_phids) 37 + ->execute(); 37 38 } else { 38 39 $unit_data = array(); 39 40 }
+4 -1
src/applications/harbormaster/controller/HarbormasterUnitMessageViewController.php
··· 12 12 13 13 $message_id = $request->getURIData('id'); 14 14 15 - $message = id(new HarbormasterBuildUnitMessage())->load($message_id); 15 + $message = id(new HarbormasterBuildUnitMessageQuery()) 16 + ->setViewer($viewer) 17 + ->withIDs(array($message_id)) 18 + ->executeOne(); 16 19 if (!$message) { 17 20 return new Aphront404Response(); 18 21 }
+64
src/applications/harbormaster/query/HarbormasterBuildUnitMessageQuery.php
··· 1 + <?php 2 + 3 + final class HarbormasterBuildUnitMessageQuery 4 + extends PhabricatorCursorPagedPolicyAwareQuery { 5 + 6 + private $ids; 7 + private $phids; 8 + private $targetPHIDs; 9 + 10 + public function withIDs(array $ids) { 11 + $this->ids = $ids; 12 + return $this; 13 + } 14 + 15 + public function withPHIDs(array $phids) { 16 + $this->phids = $phids; 17 + return $this; 18 + } 19 + 20 + public function withBuildTargetPHIDs(array $target_phids) { 21 + $this->targetPHIDs = $target_phids; 22 + return $this; 23 + } 24 + 25 + public function newResultObject() { 26 + return new HarbormasterBuildUnitMessage(); 27 + } 28 + 29 + protected function loadPage() { 30 + return $this->loadStandardPage($this->newResultObject()); 31 + } 32 + 33 + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 34 + $where = parent::buildWhereClauseParts($conn); 35 + 36 + if ($this->ids !== null) { 37 + $where[] = qsprintf( 38 + $conn, 39 + 'id IN (%Ld)', 40 + $this->ids); 41 + } 42 + 43 + if ($this->phids !== null) { 44 + $where[] = qsprintf( 45 + $conn, 46 + 'phid in (%Ls)', 47 + $this->phids); 48 + } 49 + 50 + if ($this->targetPHIDs !== null) { 51 + $where[] = qsprintf( 52 + $conn, 53 + 'buildTargetPHID in (%Ls)', 54 + $this->targetPHIDs); 55 + } 56 + 57 + return $where; 58 + } 59 + 60 + public function getQueryApplicationClass() { 61 + return 'PhabricatorHarbormasterApplication'; 62 + } 63 + 64 + }
+23 -1
src/applications/harbormaster/storage/build/HarbormasterBuildUnitMessage.php
··· 1 1 <?php 2 2 3 3 final class HarbormasterBuildUnitMessage 4 - extends HarbormasterDAO { 4 + extends HarbormasterDAO 5 + implements PhabricatorPolicyInterface { 5 6 6 7 protected $buildTargetPHID; 7 8 protected $engine; ··· 257 258 ); 258 259 259 260 return implode("\0", $parts); 261 + } 262 + 263 + 264 + /* -( PhabricatorPolicyInterface )----------------------------------------- */ 265 + 266 + 267 + public function getCapabilities() { 268 + return array( 269 + PhabricatorPolicyCapability::CAN_VIEW, 270 + ); 271 + } 272 + 273 + public function getPolicy($capability) { 274 + switch ($capability) { 275 + case PhabricatorPolicyCapability::CAN_VIEW: 276 + return PhabricatorPolicies::getMostOpenPolicy(); 277 + } 278 + } 279 + 280 + public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 281 + return false; 260 282 } 261 283 262 284 }