@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

Remove several pieces of audit-related code

Summary: Ref T10978. This code (mostly related to the old ADD_AUDIT transaction and some to the "store English text in the database" audit reasons) is no longer reachable.

Test Plan:
Grepped for removed symbols:

- withAuditStatus
- getActionNameMap (unrelated callsites exist)
- getActionName (unrelated callsites exist)
- getActionPastTenseVerb
- addAuditReason
- getAuditReasons
- auditReasonMap

Also audited some commits.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10978

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

+2 -127
+1 -1
src/applications/audit/conduit/AuditQueryConduitAPIMethod.php
··· 112 112 'id' => $request->getID(), 113 113 'commitPHID' => $request->getCommitPHID(), 114 114 'auditorPHID' => $request->getAuditorPHID(), 115 - 'reasons' => $request->getAuditReasons(), 115 + 'reasons' => array(), 116 116 'status' => $request->getAuditStatus(), 117 117 ); 118 118 }
-32
src/applications/audit/constants/PhabricatorAuditActionConstants.php
··· 12 12 const INLINE = 'audit:inline'; 13 13 const ACTION = 'audit:action'; 14 14 15 - public static function getActionNameMap() { 16 - $map = array( 17 - self::COMMENT => pht('Comment'), 18 - self::CONCERN => pht("Raise Concern \xE2\x9C\x98"), 19 - self::ACCEPT => pht("Accept Commit \xE2\x9C\x94"), 20 - self::RESIGN => pht('Resign from Audit'), 21 - self::CLOSE => pht('Close Audit'), 22 - self::ADD_CCS => pht('Add Subscribers'), 23 - self::ADD_AUDITORS => pht('Add Auditors'), 24 - ); 25 - 26 - return $map; 27 - } 28 - 29 - public static function getActionName($constant) { 30 - $map = self::getActionNameMap(); 31 - return idx($map, $constant, pht('Unknown')); 32 - } 33 - 34 - public static function getActionPastTenseVerb($action) { 35 - $map = array( 36 - self::COMMENT => pht('commented on'), 37 - self::CONCERN => pht('raised a concern with'), 38 - self::ACCEPT => pht('accepted'), 39 - self::RESIGN => pht('resigned from'), 40 - self::CLOSE => pht('closed'), 41 - self::ADD_CCS => pht('added CCs to'), 42 - self::ADD_AUDITORS => pht('added auditors to'), 43 - ); 44 - return idx($map, $action, pht('updated')); 45 - } 46 - 47 15 }
+1 -80
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 5 5 6 6 const MAX_FILES_SHOWN_IN_EMAIL = 1000; 7 7 8 - private $auditReasonMap = array(); 9 8 private $affectedFiles; 10 9 private $rawPatch; 11 10 private $auditorPHIDs = array(); 12 11 13 12 private $didExpandInlineState = false; 14 13 private $oldAuditStatus = null; 15 - 16 - public function addAuditReason($phid, $reason) { 17 - if (!isset($this->auditReasonMap[$phid])) { 18 - $this->auditReasonMap[$phid] = array(); 19 - } 20 - $this->auditReasonMap[$phid][] = $reason; 21 - return $this; 22 - } 23 - 24 - private function getAuditReasons($phid) { 25 - if (isset($this->auditReasonMap[$phid])) { 26 - return $this->auditReasonMap[$phid]; 27 - } 28 - if ($this->getIsHeraldEditor()) { 29 - $name = 'herald'; 30 - } else { 31 - $name = $this->getActor()->getUsername(); 32 - } 33 - return array(pht('Added by %s.', $name)); 34 - } 35 14 36 15 public function setRawPatch($patch) { 37 16 $this->rawPatch = $patch; ··· 62 41 // TODO: These will get modernized eventually, but that can happen one 63 42 // at a time later on. 64 43 $types[] = PhabricatorAuditActionConstants::INLINE; 65 - $types[] = PhabricatorAuditActionConstants::ADD_AUDITORS; 66 44 67 45 return $types; 68 46 } ··· 107 85 case PhabricatorAuditActionConstants::INLINE: 108 86 case PhabricatorAuditTransaction::TYPE_COMMIT: 109 87 return null; 110 - case PhabricatorAuditActionConstants::ADD_AUDITORS: 111 - // TODO: For now, just record the added PHIDs. Eventually, turn these 112 - // into real edge transactions, probably? 113 - return array(); 114 88 } 115 89 116 90 return parent::getCustomTransactionOldValue($object, $xaction); ··· 122 96 123 97 switch ($xaction->getTransactionType()) { 124 98 case PhabricatorAuditActionConstants::INLINE: 125 - case PhabricatorAuditActionConstants::ADD_AUDITORS: 126 99 case PhabricatorAuditTransaction::TYPE_COMMIT: 127 100 return $xaction->getNewValue(); 128 101 } ··· 136 109 137 110 switch ($xaction->getTransactionType()) { 138 111 case PhabricatorAuditActionConstants::INLINE: 139 - case PhabricatorAuditActionConstants::ADD_AUDITORS: 140 112 case PhabricatorAuditTransaction::TYPE_COMMIT: 141 113 return; 142 114 } ··· 157 129 $reply->setHasReplies(1)->save(); 158 130 } 159 131 return; 160 - case PhabricatorAuditActionConstants::ADD_AUDITORS: 161 - $new = $xaction->getNewValue(); 162 - if (!is_array($new)) { 163 - $new = array(); 164 - } 165 - 166 - $old = $xaction->getOldValue(); 167 - if (!is_array($old)) { 168 - $old = array(); 169 - } 170 - 171 - $add = array_diff_key($new, $old); 172 - 173 - $actor = $this->requireActor(); 174 - 175 - $requests = $object->getAudits(); 176 - $requests = mpull($requests, null, 'getAuditorPHID'); 177 - foreach ($add as $phid) { 178 - if (isset($requests[$phid])) { 179 - $request = $requests[$phid]; 180 - 181 - // Only update an existing request if the current status is not 182 - // an interesting status. 183 - if ($request->isInteresting()) { 184 - continue; 185 - } 186 - } else { 187 - $request = id(new PhabricatorRepositoryAuditRequest()) 188 - ->setCommitPHID($object->getPHID()) 189 - ->setAuditorPHID($phid); 190 - } 191 - 192 - if ($this->getIsHeraldEditor()) { 193 - $audit_requested = $xaction->getMetadataValue('auditStatus'); 194 - $audit_reason_map = $xaction->getMetadataValue('auditReasonMap'); 195 - $audit_reason = $audit_reason_map[$phid]; 196 - } else { 197 - $audit_requested = PhabricatorAuditStatusConstants::AUDIT_REQUESTED; 198 - $audit_reason = $this->getAuditReasons($phid); 199 - } 200 - 201 - $request 202 - ->setAuditStatus($audit_requested) 203 - ->setAuditReasons($audit_reason) 204 - ->save(); 205 - 206 - $requests[$phid] = $request; 207 - } 208 - 209 - $object->attachAudits($requests); 210 - return; 211 132 } 212 133 213 134 return parent::applyCustomExternalTransaction($object, $xaction); ··· 389 310 return array(); 390 311 } 391 312 392 - return id(new PhabricatorAuditTransaction()) 313 + return $commit->getApplicationTransactionTemplate() 393 314 ->setTransactionType(DiffusionCommitAuditorsTransaction::TRANSACTIONTYPE) 394 315 ->setNewValue( 395 316 array(
-6
src/applications/diffusion/controller/DiffusionCommitController.php
··· 855 855 PhabricatorAuditStatusConstants::getStatusColor($code), 856 856 PhabricatorAuditStatusConstants::getStatusName($code)); 857 857 858 - $note = array(); 859 - foreach ($request->getAuditReasons() as $reason) { 860 - $note[] = phutil_tag('div', array(), $reason); 861 - } 862 - $item->setNote($note); 863 - 864 858 $auditor_phid = $request->getAuditorPHID(); 865 859 $target = $viewer->renderHandle($auditor_phid); 866 860 $item->setTarget($target);
-8
src/applications/diffusion/query/DiffusionCommitQuery.php
··· 135 135 return $this; 136 136 } 137 137 138 - public function withAuditStatus($status) { 139 - // TODO: Replace callers with `withStatuses()`. 140 - return $this->withStatuses( 141 - array( 142 - $status, 143 - )); 144 - } 145 - 146 138 public function withEpochRange($min, $max) { 147 139 $this->epochMin = $min; 148 140 $this->epochMax = $max;