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

Move many task status hardcodes into ManiphestTaskStatus

Summary:
Ref T1812. This cleans up most of the easy hard-coded references to specific statuses:

- The "fixes" language moves into ManiphestTaskStatus.
- Add a method to list open statuses.
- Add a method to test if a status is open.
- Add a method to get default status for new tasks.

Test Plan: Browsed around, lint, grep, created, filtered and updated tasks.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1812

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

+94 -88
+5 -2
resources/sql/patches/20130913.maniphest.1.migratesearch.php
··· 13 13 $search_table = new PhabricatorSearchQuery(); 14 14 $search_conn_w = $search_table->establishConnection('w'); 15 15 16 + // See T1812. This is an old status constant from the time of this migration. 17 + $old_open_status = 0; 18 + 16 19 echo "Updating saved Maniphest queries...\n"; 17 20 $rows = new LiskRawMigrationIterator($conn_w, 'maniphest_savedquery'); 18 21 foreach ($rows as $row) { ··· 132 135 if ($include_open xor $include_closed) { 133 136 if ($include_open) { 134 137 $new_data['statuses'] = array( 135 - ManiphestTaskStatus::STATUS_OPEN, 138 + $old_open_status, 136 139 ); 137 140 } else { 138 141 $statuses = array(); 139 142 foreach (ManiphestTaskStatus::getTaskStatusMap() as $status => $n) { 140 - if ($status != ManiphestTaskStatus::STATUS_OPEN) { 143 + if ($status != $old_open_status) { 141 144 $statuses[] = $status; 142 145 } 143 146 }
+4 -36
src/applications/differential/field/specification/DifferentialFreeformFieldSpecification.php
··· 9 9 return array(); 10 10 } 11 11 12 - $prefixes = array( 13 - 'resolve' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 14 - 'resolves' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 15 - 'resolved' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 16 - 'fix' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 17 - 'fixes' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 18 - 'fixed' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 19 - 'wontfix' => ManiphestTaskStatus::STATUS_CLOSED_WONTFIX, 20 - 'wontfixes' => ManiphestTaskStatus::STATUS_CLOSED_WONTFIX, 21 - 'wontfixed' => ManiphestTaskStatus::STATUS_CLOSED_WONTFIX, 22 - 'spite' => ManiphestTaskStatus::STATUS_CLOSED_SPITE, 23 - 'spites' => ManiphestTaskStatus::STATUS_CLOSED_SPITE, 24 - 'spited' => ManiphestTaskStatus::STATUS_CLOSED_SPITE, 25 - 'invalidate' => ManiphestTaskStatus::STATUS_CLOSED_INVALID, 26 - 'invaldiates' => ManiphestTaskStatus::STATUS_CLOSED_INVALID, 27 - 'invalidated' => ManiphestTaskStatus::STATUS_CLOSED_INVALID, 28 - 'close' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 29 - 'closes' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 30 - 'closed' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 31 - 'ref' => null, 32 - 'refs' => null, 33 - 'references' => null, 34 - 'cf.' => null, 35 - ); 36 - 37 - $suffixes = array( 38 - 'as resolved' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 39 - 'as fixed' => ManiphestTaskStatus::STATUS_CLOSED_RESOLVED, 40 - 'as wontfix' => ManiphestTaskStatus::STATUS_CLOSED_WONTFIX, 41 - 'as spite' => ManiphestTaskStatus::STATUS_CLOSED_SPITE, 42 - 'out of spite' => ManiphestTaskStatus::STATUS_CLOSED_SPITE, 43 - 'as invalid' => ManiphestTaskStatus::STATUS_CLOSED_INVALID, 44 - '' => null, 45 - ); 12 + $prefixes = ManiphestTaskStatus::getStatusPrefixMap(); 13 + $suffixes = ManiphestTaskStatus::getStatusSuffixMap(); 46 14 47 15 $matches = id(new ManiphestCustomFieldStatusParser()) 48 16 ->parseCorpus($message); ··· 200 168 continue; 201 169 } 202 170 203 - if ($task->getStatus() != ManiphestTaskStatus::STATUS_OPEN) { 204 - // Task is already closed. 171 + if ($task->getStatus() == $status) { 172 + // Task is already in the specified status, so skip updating it. 205 173 continue; 206 174 } 207 175
+3 -3
src/applications/home/controller/PhabricatorHomeMainController.php
··· 118 118 119 119 $task_query = id(new ManiphestTaskQuery()) 120 120 ->setViewer($user) 121 - ->withStatuses(array(ManiphestTaskStatus::STATUS_OPEN)) 121 + ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 122 122 ->withPriorities(array($unbreak_now)) 123 123 ->setLimit(10); 124 124 ··· 157 157 if ($projects) { 158 158 $task_query = id(new ManiphestTaskQuery()) 159 159 ->setViewer($user) 160 - ->withStatuses(array(ManiphestTaskStatus::STATUS_OPEN)) 160 + ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 161 161 ->withPriorities(array($needs_triage)) 162 162 ->withAnyProjects(mpull($projects, 'getPHID')) 163 163 ->setLimit(10); ··· 250 250 251 251 $task_query = id(new ManiphestTaskQuery()) 252 252 ->setViewer($user) 253 - ->withStatus(ManiphestTaskQuery::STATUS_OPEN) 253 + ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 254 254 ->setGroupBy(ManiphestTaskQuery::GROUP_PRIORITY) 255 255 ->withOwners(array($user_phid)) 256 256 ->setLimit(10);
+1 -1
src/applications/maniphest/application/PhabricatorApplicationManiphest.php
··· 73 73 74 74 $query = id(new ManiphestTaskQuery()) 75 75 ->setViewer($user) 76 - ->withStatus(ManiphestTaskQuery::STATUS_OPEN) 76 + ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 77 77 ->withOwners(array($user->getPHID())); 78 78 $count = count($query->execute()); 79 79
+1 -1
src/applications/maniphest/conduit/ConduitAPI_maniphest_Method.php
··· 63 63 $task->setTitle((string)$request->getValue('title')); 64 64 $task->setDescription((string)$request->getValue('description')); 65 65 $changes[ManiphestTransaction::TYPE_STATUS] = 66 - ManiphestTaskStatus::STATUS_OPEN; 66 + ManiphestTaskStatus::getDefaultStatus(); 67 67 } else { 68 68 69 69 $comments = $request->getValue('comments');
+59
src/applications/maniphest/constants/ManiphestTaskStatus.php
··· 98 98 99 99 return $tag; 100 100 } 101 + 102 + public static function getDefaultStatus() { 103 + return self::STATUS_OPEN; 104 + } 105 + 106 + public static function getOpenStatusConstants() { 107 + return array( 108 + self::STATUS_OPEN, 109 + ); 110 + } 111 + 112 + public static function isOpenStatus($status) { 113 + foreach (self::getOpenStatusConstants() as $constant) { 114 + if ($status == $constant) { 115 + return true; 116 + } 117 + } 118 + return false; 119 + } 120 + 121 + public static function getStatusPrefixMap() { 122 + return array( 123 + 'resolve' => self::STATUS_CLOSED_RESOLVED, 124 + 'resolves' => self::STATUS_CLOSED_RESOLVED, 125 + 'resolved' => self::STATUS_CLOSED_RESOLVED, 126 + 'fix' => self::STATUS_CLOSED_RESOLVED, 127 + 'fixes' => self::STATUS_CLOSED_RESOLVED, 128 + 'fixed' => self::STATUS_CLOSED_RESOLVED, 129 + 'wontfix' => self::STATUS_CLOSED_WONTFIX, 130 + 'wontfixes' => self::STATUS_CLOSED_WONTFIX, 131 + 'wontfixed' => self::STATUS_CLOSED_WONTFIX, 132 + 'spite' => self::STATUS_CLOSED_SPITE, 133 + 'spites' => self::STATUS_CLOSED_SPITE, 134 + 'spited' => self::STATUS_CLOSED_SPITE, 135 + 'invalidate' => self::STATUS_CLOSED_INVALID, 136 + 'invaldiates' => self::STATUS_CLOSED_INVALID, 137 + 'invalidated' => self::STATUS_CLOSED_INVALID, 138 + 'close' => self::STATUS_CLOSED_RESOLVED, 139 + 'closes' => self::STATUS_CLOSED_RESOLVED, 140 + 'closed' => self::STATUS_CLOSED_RESOLVED, 141 + 'ref' => null, 142 + 'refs' => null, 143 + 'references' => null, 144 + 'cf.' => null, 145 + ); 146 + } 147 + 148 + public static function getStatusSuffixMap() { 149 + return array( 150 + 'as resolved' => self::STATUS_CLOSED_RESOLVED, 151 + 'as fixed' => self::STATUS_CLOSED_RESOLVED, 152 + 'as wontfix' => self::STATUS_CLOSED_WONTFIX, 153 + 'as spite' => self::STATUS_CLOSED_SPITE, 154 + 'out of spite' => self::STATUS_CLOSED_SPITE, 155 + 'as invalid' => self::STATUS_CLOSED_INVALID, 156 + ); 157 + } 158 + 159 + 101 160 }
+1 -1
src/applications/maniphest/controller/ManiphestReportController.php
··· 380 380 381 381 $query = id(new ManiphestTaskQuery()) 382 382 ->setViewer($user) 383 - ->withStatus(ManiphestTaskQuery::STATUS_OPEN); 383 + ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()); 384 384 385 385 $project_phid = $request->getStr('project'); 386 386 $project_handle = null;
+2 -32
src/applications/maniphest/field/parser/ManiphestCustomFieldStatusParser.php
··· 4 4 extends PhabricatorCustomFieldMonogramParser { 5 5 6 6 protected function getPrefixes() { 7 - return array( 8 - 'resolve', 9 - 'resolves', 10 - 'resolved', 11 - 'fix', 12 - 'fixes', 13 - 'fixed', 14 - 'wontfix', 15 - 'wontfixes', 16 - 'wontfixed', 17 - 'spite', 18 - 'spites', 19 - 'spited', 20 - 'invalidate', 21 - 'invalidates', 22 - 'invalidated', 23 - 'close', 24 - 'closes', 25 - 'closed', 26 - 'ref', 27 - 'refs', 28 - 'references', 29 - 'cf.', 30 - ); 7 + return array_keys(ManiphestTaskStatus::getStatusPrefixMap()); 31 8 } 32 9 33 10 protected function getInfixes() { ··· 42 19 } 43 20 44 21 protected function getSuffixes() { 45 - return array( 46 - 'as resolved', 47 - 'as fixed', 48 - 'as wontfix', 49 - 'as spite', 50 - 'out of spite', 51 - 'as invalid', 52 - ); 22 + return array_keys(ManiphestTaskStatus::getStatusSuffixMap()); 53 23 } 54 24 55 25 protected function getMonogramPattern() {
+2 -3
src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php
··· 9 9 ->loadOneWhere('phid = %s', $authorPHID); 10 10 $task = ManiphestTask::initializeNewTask($author) 11 11 ->setSubPriority($this->generateTaskSubPriority()) 12 - ->setTitle($this->generateTitle()) 13 - ->setStatus(ManiphestTaskStatus::STATUS_OPEN); 12 + ->setTitle($this->generateTitle()); 14 13 15 14 $content_source = PhabricatorContentSource::newForSource( 16 15 PhabricatorContentSource::SOURCE_UNKNOWN, ··· 101 100 // Make sure 4/5th of all generated Tasks are open 102 101 $random = rand(0, 4); 103 102 if ($random != 0) { 104 - return ManiphestTaskStatus::STATUS_OPEN; 103 + return ManiphestTaskStatus::getDefaultStatus(); 105 104 } else { 106 105 return array_rand($statuses); 107 106 }
+1 -1
src/applications/maniphest/mail/ManiphestReplyHandler.php
··· 64 64 // and then set the title and description. 65 65 $xaction = clone $template; 66 66 $xaction->setTransactionType(ManiphestTransaction::TYPE_STATUS); 67 - $xaction->setNewValue(ManiphestTaskStatus::STATUS_OPEN); 67 + $xaction->setNewValue(ManiphestTaskStatus::getDefaultStatus()); 68 68 $xactions[] = $xaction; 69 69 70 70 $task->setAuthorPHID($user->getPHID());
+1 -1
src/applications/maniphest/phid/ManiphestPHIDTypeTask.php
··· 38 38 $handle->setFullName("T{$id}: {$title}"); 39 39 $handle->setURI("/T{$id}"); 40 40 41 - if ($task->getStatus() != ManiphestTaskStatus::STATUS_OPEN) { 41 + if (!ManiphestTaskStatus::isOpenStatus($task->getStatus())) { 42 42 $handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED); 43 43 } 44 44 }
+9 -3
src/applications/maniphest/query/ManiphestTaskSearchEngine.php
··· 384 384 case 'assigned': 385 385 return $query 386 386 ->setParameter('assignedPHIDs', array($viewer_phid)) 387 - ->setParameter('statuses', array(ManiphestTaskStatus::STATUS_OPEN)); 387 + ->setParameter( 388 + 'statuses', 389 + ManiphestTaskStatus::getOpenStatusConstants()); 388 390 case 'subscribed': 389 391 return $query 390 392 ->setParameter('subscriberPHIDs', array($viewer_phid)) 391 - ->setParameter('statuses', array(ManiphestTaskStatus::STATUS_OPEN)); 393 + ->setParameter( 394 + 'statuses', 395 + ManiphestTaskStatus::getOpenStatusConstants()); 392 396 case 'open': 393 397 return $query 394 - ->setParameter('statuses', array(ManiphestTaskStatus::STATUS_OPEN)); 398 + ->setParameter( 399 + 'statuses', 400 + ManiphestTaskStatus::getOpenStatusConstants()); 395 401 case 'authored': 396 402 return $query 397 403 ->setParameter('authorPHIDs', array($viewer_phid))
+1 -1
src/applications/maniphest/search/ManiphestSearchIndexer.php
··· 31 31 $task->getDateCreated()); 32 32 33 33 $doc->addRelationship( 34 - ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) 34 + (ManiphestTaskStatus::isOpenStatus($task->getStatus())) 35 35 ? PhabricatorSearchRelationship::RELATIONSHIP_OPEN 36 36 : PhabricatorSearchRelationship::RELATIONSHIP_CLOSED, 37 37 $task->getPHID(),
+2 -1
src/applications/maniphest/storage/ManiphestTask.php
··· 15 15 protected $ownerPHID; 16 16 protected $ccPHIDs = array(); 17 17 18 - protected $status = ManiphestTaskStatus::STATUS_OPEN; 18 + protected $status; 19 19 protected $priority; 20 20 protected $subpriority = 0; 21 21 ··· 47 47 $edit_policy = $app->getPolicy(ManiphestCapabilityDefaultEdit::CAPABILITY); 48 48 49 49 return id(new ManiphestTask()) 50 + ->setStatus(ManiphestTaskStatus::getDefaultStatus()) 50 51 ->setPriority(ManiphestTaskPriority::getDefaultPriority()) 51 52 ->setAuthorPHID($actor->getPHID()) 52 53 ->setViewPolicy($view_policy)
+1 -1
src/applications/project/controller/PhabricatorProjectBoardController.php
··· 51 51 $tasks = id(new ManiphestTaskQuery()) 52 52 ->setViewer($viewer) 53 53 ->withAllProjects(array($project->getPHID())) 54 - ->withStatus(ManiphestTaskQuery::STATUS_OPEN) 54 + ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 55 55 ->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY) 56 56 ->execute(); 57 57 $tasks = mpull($tasks, null, 'getPHID');
+1 -1
src/applications/project/controller/PhabricatorProjectProfileController.php
··· 129 129 $query = id(new ManiphestTaskQuery()) 130 130 ->setViewer($user) 131 131 ->withAnyProjects(array($project->getPHID())) 132 - ->withStatus(ManiphestTaskQuery::STATUS_OPEN) 132 + ->withStatuses(ManiphestTaskStatus::getOpenStatusConstants()) 133 133 ->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY) 134 134 ->setLimit(10); 135 135 $tasks = $query->execute();