@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 a bunch of reundant checks for transactions with no effect from Maniphest

Summary: Ref T2217. These checks are no longer necessary, ApplicationTransactions handle them for us.

Test Plan:
- Made a no-effect edit, verified no new transactions showed up.
- Made real edits, saw them happen and leave transactions.
- Made an edit which just reorders CCs, saw it detected as no-effect.
- As above, with projects.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2217

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

+36 -54
+12 -50
src/applications/maniphest/controller/ManiphestTaskEditController.php
··· 104 104 $new_desc = $request->getStr('description'); 105 105 $new_status = $request->getStr('status'); 106 106 107 - $workflow = ''; 108 - 109 - if ($new_title != $task->getTitle()) { 110 - $changes[ManiphestTransaction::TYPE_TITLE] = $new_title; 111 - } 112 - if ($new_desc != $task->getDescription()) { 113 - $changes[ManiphestTransaction::TYPE_DESCRIPTION] = $new_desc; 114 - } 115 - if ($new_status != $task->getStatus()) { 116 - $changes[ManiphestTransaction::TYPE_STATUS] = $new_status; 117 - } 118 - 119 107 if (!$task->getID()) { 120 108 $workflow = 'create'; 109 + } else { 110 + $workflow = ''; 121 111 } 112 + 113 + $changes[ManiphestTransaction::TYPE_TITLE] = $new_title; 114 + $changes[ManiphestTransaction::TYPE_DESCRIPTION] = $new_desc; 115 + $changes[ManiphestTransaction::TYPE_STATUS] = $new_status; 122 116 123 117 $owner_tokenizer = $request->getArr('assigned_to'); 124 118 $owner_phid = reset($owner_tokenizer); ··· 168 162 $task->setCCPHIDs($request->getArr('cc')); 169 163 $task->setProjectPHIDs($request->getArr('projects')); 170 164 } else { 171 - if ($request->getInt('priority') != $task->getPriority()) { 172 - $changes[ManiphestTransaction::TYPE_PRIORITY] = 173 - $request->getInt('priority'); 174 - } 175 165 176 - if ($owner_phid != $task->getOwnerPHID()) { 177 - $changes[ManiphestTransaction::TYPE_OWNER] = $owner_phid; 178 - } 179 - 180 - if ($request->getArr('cc') != $task->getCCPHIDs()) { 181 - $changes[ManiphestTransaction::TYPE_CCS] = $request->getArr('cc'); 182 - } 183 - 184 - $new_proj_arr = $request->getArr('projects'); 185 - $new_proj_arr = array_values($new_proj_arr); 186 - sort($new_proj_arr); 187 - 188 - $cur_proj_arr = $task->getProjectPHIDs(); 189 - $cur_proj_arr = array_values($cur_proj_arr); 190 - sort($cur_proj_arr); 191 - 192 - if ($new_proj_arr != $cur_proj_arr) { 193 - $changes[ManiphestTransaction::TYPE_PROJECTS] = $new_proj_arr; 194 - } 166 + $changes[ManiphestTransaction::TYPE_PRIORITY] = 167 + $request->getInt('priority'); 168 + $changes[ManiphestTransaction::TYPE_OWNER] = $owner_phid; 169 + $changes[ManiphestTransaction::TYPE_CCS] = $request->getArr('cc'); 170 + $changes[ManiphestTransaction::TYPE_PROJECTS] = 171 + $request->getArr('projects'); 195 172 196 173 if ($files) { 197 174 $file_map = mpull($files, 'getPHID'); ··· 201 178 ); 202 179 } 203 180 204 - $content_source = PhabricatorContentSource::newForSource( 205 - PhabricatorContentSource::SOURCE_WEB, 206 - array( 207 - 'ip' => $request->getRemoteAddr(), 208 - )); 209 - 210 181 $template = new ManiphestTransaction(); 211 182 $transactions = array(); 212 183 ··· 226 197 $transaction->setMetadataValue('customfield:key', $aux_key); 227 198 $old = idx($old_values, $aux_key); 228 199 $new = $aux_field->getNewValueForApplicationTransactions(); 229 - 230 - // TODO: This is a ghetto check for transactions with no effect. 231 - if (!is_array($old) && !is_array($new)) { 232 - if ((string)$old === (string)$new) { 233 - continue; 234 - } 235 - } else if ($old == $new) { 236 - continue; 237 - } 238 200 239 201 $transaction->setOldValue($old); 240 202 $transaction->setNewValue($new);
+24 -4
src/applications/maniphest/editor/ManiphestTransactionEditorPro.php
··· 34 34 case ManiphestTransaction::TYPE_DESCRIPTION: 35 35 return $object->getDescription(); 36 36 case ManiphestTransaction::TYPE_OWNER: 37 - return $object->getOwnerPHID(); 37 + return nonempty($object->getOwnerPHID(), null); 38 38 case ManiphestTransaction::TYPE_CCS: 39 39 return array_values(array_unique($object->getCCPHIDs())); 40 40 case ManiphestTransaction::TYPE_PROJECTS: 41 - return $object->getProjectPHIDs(); 41 + return array_values(array_unique($object->getProjectPHIDs())); 42 42 case ManiphestTransaction::TYPE_ATTACH: 43 43 return $object->getAttached(); 44 44 case ManiphestTransaction::TYPE_EDGE: ··· 57 57 case ManiphestTransaction::TYPE_STATUS: 58 58 return (int)$xaction->getNewValue(); 59 59 case ManiphestTransaction::TYPE_CCS: 60 + case ManiphestTransaction::TYPE_PROJECTS: 60 61 return array_values(array_unique($xaction->getNewValue())); 62 + case ManiphestTransaction::TYPE_OWNER: 63 + return nonempty($xaction->getNewValue(), null); 61 64 case ManiphestTransaction::TYPE_TITLE: 62 65 case ManiphestTransaction::TYPE_DESCRIPTION: 63 - case ManiphestTransaction::TYPE_OWNER: 64 - case ManiphestTransaction::TYPE_PROJECTS: 65 66 case ManiphestTransaction::TYPE_ATTACH: 66 67 case ManiphestTransaction::TYPE_EDGE: 67 68 return $xaction->getNewValue(); 68 69 } 69 70 70 71 } 72 + 73 + protected function transactionHasEffect( 74 + PhabricatorLiskDAO $object, 75 + PhabricatorApplicationTransaction $xaction) { 76 + 77 + $old = $xaction->getOldValue(); 78 + $new = $xaction->getNewValue(); 79 + 80 + switch ($xaction->getTransactionType()) { 81 + case ManiphestTransaction::TYPE_PROJECTS: 82 + case ManiphestTransaction::TYPE_CCS: 83 + sort($old); 84 + sort($new); 85 + return ($old !== $new); 86 + } 87 + 88 + return parent::transactionHasEffect($object, $xaction); 89 + } 90 + 71 91 72 92 protected function applyCustomInternalTransaction( 73 93 PhabricatorLiskDAO $object,