1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

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
This commit is contained in:
epriestley 2017-01-26 10:32:29 -08:00
parent 2e9cc5e8e8
commit bcbd4035fd
5 changed files with 2 additions and 127 deletions

View file

@ -112,7 +112,7 @@ final class AuditQueryConduitAPIMethod extends AuditConduitAPIMethod {
'id' => $request->getID(),
'commitPHID' => $request->getCommitPHID(),
'auditorPHID' => $request->getAuditorPHID(),
'reasons' => $request->getAuditReasons(),
'reasons' => array(),
'status' => $request->getAuditStatus(),
);
}

View file

@ -12,36 +12,4 @@ final class PhabricatorAuditActionConstants extends Phobject {
const INLINE = 'audit:inline';
const ACTION = 'audit:action';
public static function getActionNameMap() {
$map = array(
self::COMMENT => pht('Comment'),
self::CONCERN => pht("Raise Concern \xE2\x9C\x98"),
self::ACCEPT => pht("Accept Commit \xE2\x9C\x94"),
self::RESIGN => pht('Resign from Audit'),
self::CLOSE => pht('Close Audit'),
self::ADD_CCS => pht('Add Subscribers'),
self::ADD_AUDITORS => pht('Add Auditors'),
);
return $map;
}
public static function getActionName($constant) {
$map = self::getActionNameMap();
return idx($map, $constant, pht('Unknown'));
}
public static function getActionPastTenseVerb($action) {
$map = array(
self::COMMENT => pht('commented on'),
self::CONCERN => pht('raised a concern with'),
self::ACCEPT => pht('accepted'),
self::RESIGN => pht('resigned from'),
self::CLOSE => pht('closed'),
self::ADD_CCS => pht('added CCs to'),
self::ADD_AUDITORS => pht('added auditors to'),
);
return idx($map, $action, pht('updated'));
}
}

View file

@ -5,7 +5,6 @@ final class PhabricatorAuditEditor
const MAX_FILES_SHOWN_IN_EMAIL = 1000;
private $auditReasonMap = array();
private $affectedFiles;
private $rawPatch;
private $auditorPHIDs = array();
@ -13,26 +12,6 @@ final class PhabricatorAuditEditor
private $didExpandInlineState = false;
private $oldAuditStatus = null;
public function addAuditReason($phid, $reason) {
if (!isset($this->auditReasonMap[$phid])) {
$this->auditReasonMap[$phid] = array();
}
$this->auditReasonMap[$phid][] = $reason;
return $this;
}
private function getAuditReasons($phid) {
if (isset($this->auditReasonMap[$phid])) {
return $this->auditReasonMap[$phid];
}
if ($this->getIsHeraldEditor()) {
$name = 'herald';
} else {
$name = $this->getActor()->getUsername();
}
return array(pht('Added by %s.', $name));
}
public function setRawPatch($patch) {
$this->rawPatch = $patch;
return $this;
@ -62,7 +41,6 @@ final class PhabricatorAuditEditor
// TODO: These will get modernized eventually, but that can happen one
// at a time later on.
$types[] = PhabricatorAuditActionConstants::INLINE;
$types[] = PhabricatorAuditActionConstants::ADD_AUDITORS;
return $types;
}
@ -107,10 +85,6 @@ final class PhabricatorAuditEditor
case PhabricatorAuditActionConstants::INLINE:
case PhabricatorAuditTransaction::TYPE_COMMIT:
return null;
case PhabricatorAuditActionConstants::ADD_AUDITORS:
// TODO: For now, just record the added PHIDs. Eventually, turn these
// into real edge transactions, probably?
return array();
}
return parent::getCustomTransactionOldValue($object, $xaction);
@ -122,7 +96,6 @@ final class PhabricatorAuditEditor
switch ($xaction->getTransactionType()) {
case PhabricatorAuditActionConstants::INLINE:
case PhabricatorAuditActionConstants::ADD_AUDITORS:
case PhabricatorAuditTransaction::TYPE_COMMIT:
return $xaction->getNewValue();
}
@ -136,7 +109,6 @@ final class PhabricatorAuditEditor
switch ($xaction->getTransactionType()) {
case PhabricatorAuditActionConstants::INLINE:
case PhabricatorAuditActionConstants::ADD_AUDITORS:
case PhabricatorAuditTransaction::TYPE_COMMIT:
return;
}
@ -157,57 +129,6 @@ final class PhabricatorAuditEditor
$reply->setHasReplies(1)->save();
}
return;
case PhabricatorAuditActionConstants::ADD_AUDITORS:
$new = $xaction->getNewValue();
if (!is_array($new)) {
$new = array();
}
$old = $xaction->getOldValue();
if (!is_array($old)) {
$old = array();
}
$add = array_diff_key($new, $old);
$actor = $this->requireActor();
$requests = $object->getAudits();
$requests = mpull($requests, null, 'getAuditorPHID');
foreach ($add as $phid) {
if (isset($requests[$phid])) {
$request = $requests[$phid];
// Only update an existing request if the current status is not
// an interesting status.
if ($request->isInteresting()) {
continue;
}
} else {
$request = id(new PhabricatorRepositoryAuditRequest())
->setCommitPHID($object->getPHID())
->setAuditorPHID($phid);
}
if ($this->getIsHeraldEditor()) {
$audit_requested = $xaction->getMetadataValue('auditStatus');
$audit_reason_map = $xaction->getMetadataValue('auditReasonMap');
$audit_reason = $audit_reason_map[$phid];
} else {
$audit_requested = PhabricatorAuditStatusConstants::AUDIT_REQUESTED;
$audit_reason = $this->getAuditReasons($phid);
}
$request
->setAuditStatus($audit_requested)
->setAuditReasons($audit_reason)
->save();
$requests[$phid] = $request;
}
$object->attachAudits($requests);
return;
}
return parent::applyCustomExternalTransaction($object, $xaction);
@ -389,7 +310,7 @@ final class PhabricatorAuditEditor
return array();
}
return id(new PhabricatorAuditTransaction())
return $commit->getApplicationTransactionTemplate()
->setTransactionType(DiffusionCommitAuditorsTransaction::TRANSACTIONTYPE)
->setNewValue(
array(

View file

@ -855,12 +855,6 @@ final class DiffusionCommitController extends DiffusionController {
PhabricatorAuditStatusConstants::getStatusColor($code),
PhabricatorAuditStatusConstants::getStatusName($code));
$note = array();
foreach ($request->getAuditReasons() as $reason) {
$note[] = phutil_tag('div', array(), $reason);
}
$item->setNote($note);
$auditor_phid = $request->getAuditorPHID();
$target = $viewer->renderHandle($auditor_phid);
$item->setTarget($target);

View file

@ -135,14 +135,6 @@ final class DiffusionCommitQuery
return $this;
}
public function withAuditStatus($status) {
// TODO: Replace callers with `withStatuses()`.
return $this->withStatuses(
array(
$status,
));
}
public function withEpochRange($min, $max) {
$this->epochMin = $min;
$this->epochMax = $max;