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

Remove the Maniphest-specific bulk job type

Summary: Depends on D18863. Ref PHI173. Ref T13025. After D18863, this job type is no longer used: the workflow uses a genric worker instead which can apply transactions to any object.

Test Plan: Grepped for callsites, found none.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13025

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

-305
-2
src/__phutil_library_map__.php
··· 1559 1559 'ManiphestTaskDescriptionTransaction' => 'applications/maniphest/xaction/ManiphestTaskDescriptionTransaction.php', 1560 1560 'ManiphestTaskDetailController' => 'applications/maniphest/controller/ManiphestTaskDetailController.php', 1561 1561 'ManiphestTaskEdgeTransaction' => 'applications/maniphest/xaction/ManiphestTaskEdgeTransaction.php', 1562 - 'ManiphestTaskEditBulkJobType' => 'applications/maniphest/bulk/ManiphestTaskEditBulkJobType.php', 1563 1562 'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php', 1564 1563 'ManiphestTaskEditEngineLock' => 'applications/maniphest/editor/ManiphestTaskEditEngineLock.php', 1565 1564 'ManiphestTaskFerretEngine' => 'applications/maniphest/search/ManiphestTaskFerretEngine.php', ··· 6778 6777 'ManiphestTaskDescriptionTransaction' => 'ManiphestTaskTransactionType', 6779 6778 'ManiphestTaskDetailController' => 'ManiphestController', 6780 6779 'ManiphestTaskEdgeTransaction' => 'ManiphestTaskTransactionType', 6781 - 'ManiphestTaskEditBulkJobType' => 'PhabricatorWorkerBulkJobType', 6782 6780 'ManiphestTaskEditController' => 'ManiphestController', 6783 6781 'ManiphestTaskEditEngineLock' => 'PhabricatorEditEngineLock', 6784 6782 'ManiphestTaskFerretEngine' => 'PhabricatorFerretEngine',
-303
src/applications/maniphest/bulk/ManiphestTaskEditBulkJobType.php
··· 1 - <?php 2 - 3 - final class ManiphestTaskEditBulkJobType 4 - extends PhabricatorWorkerBulkJobType { 5 - 6 - public function getBulkJobTypeKey() { 7 - return 'maniphest.task.edit'; 8 - } 9 - 10 - public function getJobName(PhabricatorWorkerBulkJob $job) { 11 - return pht('Maniphest Bulk Edit'); 12 - } 13 - 14 - public function getDescriptionForConfirm(PhabricatorWorkerBulkJob $job) { 15 - return pht( 16 - 'You are about to apply a bulk edit to Maniphest which will affect '. 17 - '%s task(s).', 18 - new PhutilNumber($job->getSize())); 19 - } 20 - 21 - public function getJobSize(PhabricatorWorkerBulkJob $job) { 22 - return count($job->getParameter('taskPHIDs', array())); 23 - } 24 - 25 - public function getDoneURI(PhabricatorWorkerBulkJob $job) { 26 - return $job->getParameter('doneURI'); 27 - } 28 - 29 - public function createTasks(PhabricatorWorkerBulkJob $job) { 30 - $tasks = array(); 31 - 32 - foreach ($job->getParameter('taskPHIDs', array()) as $phid) { 33 - $tasks[] = PhabricatorWorkerBulkTask::initializeNewTask($job, $phid); 34 - } 35 - 36 - return $tasks; 37 - } 38 - 39 - public function runTask( 40 - PhabricatorUser $actor, 41 - PhabricatorWorkerBulkJob $job, 42 - PhabricatorWorkerBulkTask $task) { 43 - 44 - $object = id(new ManiphestTaskQuery()) 45 - ->setViewer($actor) 46 - ->requireCapabilities( 47 - array( 48 - PhabricatorPolicyCapability::CAN_VIEW, 49 - PhabricatorPolicyCapability::CAN_EDIT, 50 - )) 51 - ->withPHIDs(array($task->getObjectPHID())) 52 - ->needProjectPHIDs(true) 53 - ->needSubscriberPHIDs(true) 54 - ->executeOne(); 55 - if (!$object) { 56 - return; 57 - } 58 - 59 - $field_list = PhabricatorCustomField::getObjectFields( 60 - $object, 61 - PhabricatorCustomField::ROLE_EDIT); 62 - $field_list->readFieldsFromStorage($object); 63 - 64 - $actions = $job->getParameter('actions'); 65 - $xactions = $this->buildTransactions($actions, $object); 66 - 67 - $editor = id(new ManiphestTransactionEditor()) 68 - ->setActor($actor) 69 - ->setContentSource($job->newContentSource()) 70 - ->setContinueOnNoEffect(true) 71 - ->setContinueOnMissingFields(true) 72 - ->applyTransactions($object, $xactions); 73 - } 74 - 75 - private function buildTransactions($actions, ManiphestTask $task) { 76 - $value_map = array(); 77 - $type_map = array( 78 - 'add_comment' => PhabricatorTransactions::TYPE_COMMENT, 79 - 'assign' => ManiphestTaskOwnerTransaction::TRANSACTIONTYPE, 80 - 'status' => ManiphestTaskStatusTransaction::TRANSACTIONTYPE, 81 - 'priority' => ManiphestTaskPriorityTransaction::TRANSACTIONTYPE, 82 - 'add_project' => PhabricatorTransactions::TYPE_EDGE, 83 - 'remove_project' => PhabricatorTransactions::TYPE_EDGE, 84 - 'add_ccs' => PhabricatorTransactions::TYPE_SUBSCRIBERS, 85 - 'remove_ccs' => PhabricatorTransactions::TYPE_SUBSCRIBERS, 86 - 'space' => PhabricatorTransactions::TYPE_SPACE, 87 - ); 88 - 89 - $edge_edit_types = array( 90 - 'add_project' => true, 91 - 'remove_project' => true, 92 - 'add_ccs' => true, 93 - 'remove_ccs' => true, 94 - ); 95 - 96 - $xactions = array(); 97 - foreach ($actions as $action) { 98 - if (empty($type_map[$action['action']])) { 99 - throw new Exception(pht("Unknown batch edit action '%s'!", $action)); 100 - } 101 - 102 - $type = $type_map[$action['action']]; 103 - 104 - // Figure out the current value, possibly after modifications by other 105 - // batch actions of the same type. For example, if the user chooses to 106 - // "Add Comment" twice, we should add both comments. More notably, if the 107 - // user chooses "Remove Project..." and also "Add Project...", we should 108 - // avoid restoring the removed project in the second transaction. 109 - 110 - if (array_key_exists($type, $value_map)) { 111 - $current = $value_map[$type]; 112 - } else { 113 - switch ($type) { 114 - case PhabricatorTransactions::TYPE_COMMENT: 115 - $current = null; 116 - break; 117 - case ManiphestTaskOwnerTransaction::TRANSACTIONTYPE: 118 - $current = $task->getOwnerPHID(); 119 - break; 120 - case ManiphestTaskStatusTransaction::TRANSACTIONTYPE: 121 - $current = $task->getStatus(); 122 - break; 123 - case ManiphestTaskPriorityTransaction::TRANSACTIONTYPE: 124 - $current = $task->getPriority(); 125 - break; 126 - case PhabricatorTransactions::TYPE_EDGE: 127 - $current = $task->getProjectPHIDs(); 128 - break; 129 - case PhabricatorTransactions::TYPE_SUBSCRIBERS: 130 - $current = $task->getSubscriberPHIDs(); 131 - break; 132 - case PhabricatorTransactions::TYPE_SPACE: 133 - $current = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID( 134 - $task); 135 - break; 136 - } 137 - } 138 - 139 - // Check if the value is meaningful / provided, and normalize it if 140 - // necessary. This discards, e.g., empty comments and empty owner 141 - // changes. 142 - 143 - $value = $action['value']; 144 - switch ($type) { 145 - case PhabricatorTransactions::TYPE_COMMENT: 146 - if (!strlen($value)) { 147 - continue 2; 148 - } 149 - break; 150 - case PhabricatorTransactions::TYPE_SPACE: 151 - if (empty($value)) { 152 - continue 2; 153 - } 154 - $value = head($value); 155 - break; 156 - case ManiphestTaskOwnerTransaction::TRANSACTIONTYPE: 157 - if (empty($value)) { 158 - continue 2; 159 - } 160 - $value = head($value); 161 - $no_owner = PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN; 162 - if ($value === $no_owner) { 163 - $value = null; 164 - } 165 - break; 166 - case PhabricatorTransactions::TYPE_EDGE: 167 - if (empty($value)) { 168 - continue 2; 169 - } 170 - break; 171 - case PhabricatorTransactions::TYPE_SUBSCRIBERS: 172 - if (empty($value)) { 173 - continue 2; 174 - } 175 - break; 176 - } 177 - 178 - // If the edit doesn't change anything, go to the next action. This 179 - // check is only valid for changes like "owner", "status", etc, not 180 - // for edge edits, because we should still apply an edit like 181 - // "Remove Projects: A, B" to a task with projects "A, B". 182 - 183 - if (empty($edge_edit_types[$action['action']])) { 184 - if ($value == $current) { 185 - continue; 186 - } 187 - } 188 - 189 - // Apply the value change; for most edits this is just replacement, but 190 - // some need to merge the current and edited values (add/remove project). 191 - 192 - switch ($type) { 193 - case PhabricatorTransactions::TYPE_COMMENT: 194 - if (strlen($current)) { 195 - $value = $current."\n\n".$value; 196 - } 197 - break; 198 - case PhabricatorTransactions::TYPE_EDGE: 199 - $is_remove = $action['action'] == 'remove_project'; 200 - 201 - $current = array_fill_keys($current, true); 202 - $value = array_fill_keys($value, true); 203 - 204 - $new = $current; 205 - $did_something = false; 206 - 207 - if ($is_remove) { 208 - foreach ($value as $phid => $ignored) { 209 - if (isset($new[$phid])) { 210 - unset($new[$phid]); 211 - $did_something = true; 212 - } 213 - } 214 - } else { 215 - foreach ($value as $phid => $ignored) { 216 - if (empty($new[$phid])) { 217 - $new[$phid] = true; 218 - $did_something = true; 219 - } 220 - } 221 - } 222 - 223 - if (!$did_something) { 224 - continue 2; 225 - } 226 - 227 - $value = array_keys($new); 228 - break; 229 - case PhabricatorTransactions::TYPE_SUBSCRIBERS: 230 - $is_remove = $action['action'] == 'remove_ccs'; 231 - 232 - $current = array_fill_keys($current, true); 233 - 234 - $new = array(); 235 - $did_something = false; 236 - 237 - if ($is_remove) { 238 - foreach ($value as $phid) { 239 - if (isset($current[$phid])) { 240 - $new[$phid] = true; 241 - $did_something = true; 242 - } 243 - } 244 - if ($new) { 245 - $value = array('-' => array_keys($new)); 246 - } 247 - } else { 248 - $new = array(); 249 - foreach ($value as $phid) { 250 - $new[$phid] = true; 251 - $did_something = true; 252 - } 253 - if ($new) { 254 - $value = array('+' => array_keys($new)); 255 - } 256 - } 257 - if (!$did_something) { 258 - continue 2; 259 - } 260 - 261 - break; 262 - } 263 - 264 - $value_map[$type] = $value; 265 - } 266 - 267 - $template = new ManiphestTransaction(); 268 - 269 - foreach ($value_map as $type => $value) { 270 - $xaction = clone $template; 271 - $xaction->setTransactionType($type); 272 - 273 - switch ($type) { 274 - case PhabricatorTransactions::TYPE_COMMENT: 275 - $xaction->attachComment( 276 - id(new ManiphestTransactionComment()) 277 - ->setContent($value)); 278 - break; 279 - case PhabricatorTransactions::TYPE_EDGE: 280 - $project_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 281 - $xaction 282 - ->setMetadataValue('edge:type', $project_type) 283 - ->setNewValue( 284 - array( 285 - '=' => array_fuse($value), 286 - )); 287 - break; 288 - case ManiphestTaskPriorityTransaction::TRANSACTIONTYPE: 289 - $keyword_map = ManiphestTaskPriority::getTaskPriorityKeywordsMap(); 290 - $keyword = head(idx($keyword_map, $value)); 291 - $xaction->setNewValue($keyword); 292 - break; 293 - default: 294 - $xaction->setNewValue($value); 295 - break; 296 - } 297 - 298 - $xactions[] = $xaction; 299 - } 300 - 301 - return $xactions; 302 - } 303 - }