@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 old Audit code "Action" transaction editing code

Summary:
Ref T2393. This code is no longer reachable (we never had an API for auditing in Diffusion) and unused. Clean it up before implementing new states/actions.

(Note that code for displaying these transactions still needs to stick around for a bit, we'll just never apply new ones from here on out. They've been replaced with modular transactions.)

Test Plan: Grepped for usage, commentd on / audited a commit.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T2393

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

-160
-160
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 60 60 61 61 // TODO: These will get modernized eventually, but that can happen one 62 62 // at a time later on. 63 - $types[] = PhabricatorAuditActionConstants::ACTION; 64 63 $types[] = PhabricatorAuditActionConstants::INLINE; 65 64 $types[] = PhabricatorAuditActionConstants::ADD_AUDITORS; 66 65 ··· 98 97 PhabricatorLiskDAO $object, 99 98 PhabricatorApplicationTransaction $xaction) { 100 99 switch ($xaction->getTransactionType()) { 101 - case PhabricatorAuditActionConstants::ACTION: 102 100 case PhabricatorAuditActionConstants::INLINE: 103 101 case PhabricatorAuditTransaction::TYPE_COMMIT: 104 102 return null; ··· 116 114 PhabricatorApplicationTransaction $xaction) { 117 115 118 116 switch ($xaction->getTransactionType()) { 119 - case PhabricatorAuditActionConstants::ACTION: 120 117 case PhabricatorAuditActionConstants::INLINE: 121 118 case PhabricatorAuditActionConstants::ADD_AUDITORS: 122 119 case PhabricatorAuditTransaction::TYPE_COMMIT: ··· 131 128 PhabricatorApplicationTransaction $xaction) { 132 129 133 130 switch ($xaction->getTransactionType()) { 134 - case PhabricatorAuditActionConstants::ACTION: 135 131 case PhabricatorAuditActionConstants::INLINE: 136 132 case PhabricatorAuditActionConstants::ADD_AUDITORS: 137 133 case PhabricatorAuditTransaction::TYPE_COMMIT: ··· 146 142 PhabricatorApplicationTransaction $xaction) { 147 143 148 144 switch ($xaction->getTransactionType()) { 149 - case PhabricatorAuditActionConstants::ACTION: 150 145 case PhabricatorAuditTransaction::TYPE_COMMIT: 151 146 return; 152 147 case PhabricatorAuditActionConstants::INLINE: ··· 267 262 case PhabricatorAuditTransaction::TYPE_COMMIT: 268 263 $import_status_flag = PhabricatorRepositoryCommit::IMPORTED_HERALD; 269 264 break; 270 - case PhabricatorAuditActionConstants::ACTION: 271 - $new = $xaction->getNewValue(); 272 - switch ($new) { 273 - case PhabricatorAuditActionConstants::CLOSE: 274 - // "Close" means wipe out all the concerns. 275 - $requests = $object->getAudits(); 276 - foreach ($requests as $request) { 277 - if ($request->getAuditStatus() == $status_concerned) { 278 - $request 279 - ->setAuditStatus($status_closed) 280 - ->save(); 281 - } 282 - } 283 - break; 284 - case PhabricatorAuditActionConstants::RESIGN: 285 - $requests = $object->getAudits(); 286 - $requests = mpull($requests, null, 'getAuditorPHID'); 287 - $actor_request = idx($requests, $actor_phid); 288 - 289 - // If the actor doesn't currently have a relationship to the 290 - // commit, add one explicitly. For example, this allows members 291 - // of a project to resign from a commit and have it drop out of 292 - // their queue. 293 - 294 - if (!$actor_request) { 295 - $actor_request = id(new PhabricatorRepositoryAuditRequest()) 296 - ->setCommitPHID($object->getPHID()) 297 - ->setAuditorPHID($actor_phid); 298 - 299 - $requests[] = $actor_request; 300 - $object->attachAudits($requests); 301 - } 302 - 303 - $actor_request 304 - ->setAuditStatus($status_resigned) 305 - ->save(); 306 - break; 307 - case PhabricatorAuditActionConstants::ACCEPT: 308 - case PhabricatorAuditActionConstants::CONCERN: 309 - if ($new == PhabricatorAuditActionConstants::ACCEPT) { 310 - $new_status = $status_accepted; 311 - } else { 312 - $new_status = $status_concerned; 313 - } 314 - 315 - $requests = $object->getAudits(); 316 - $requests = mpull($requests, null, 'getAuditorPHID'); 317 - 318 - // Figure out which requests the actor has authority over: these 319 - // are user requests where they are the auditor, and packages 320 - // and projects they are a member of. 321 - 322 - if ($actor_is_author) { 323 - // When modifying your own commits, you act only on behalf of 324 - // yourself, not your packages/projects -- the idea being that 325 - // you can't accept your own commits. 326 - $authority_phids = array($actor_phid); 327 - } else { 328 - $authority_phids = 329 - PhabricatorAuditCommentEditor::loadAuditPHIDsForUser( 330 - $this->requireActor()); 331 - } 332 - 333 - $authority = array_select_keys( 334 - $requests, 335 - $authority_phids); 336 - 337 - if (!$authority) { 338 - // If the actor has no authority over any existing requests, 339 - // create a new request for them. 340 - 341 - $actor_request = id(new PhabricatorRepositoryAuditRequest()) 342 - ->setCommitPHID($object->getPHID()) 343 - ->setAuditorPHID($actor_phid) 344 - ->setAuditStatus($new_status) 345 - ->save(); 346 - 347 - $requests[$actor_phid] = $actor_request; 348 - $object->attachAudits($requests); 349 - } else { 350 - // Otherwise, update the audit status of the existing requests. 351 - foreach ($authority as $request) { 352 - $request 353 - ->setAuditStatus($new_status) 354 - ->save(); 355 - } 356 - } 357 - break; 358 - 359 - } 360 - break; 361 265 } 362 266 } 363 267 ··· 423 327 if (!$this->didExpandInlineState) { 424 328 switch ($xaction->getTransactionType()) { 425 329 case PhabricatorTransactions::TYPE_COMMENT: 426 - case PhabricatorAuditActionConstants::ACTION: 427 330 $this->didExpandInlineState = true; 428 331 429 332 $actor_phid = $this->getActingAsPHID(); ··· 513 416 514 417 return array_values(array_merge($head, $tail)); 515 418 } 516 - 517 - protected function validateTransaction( 518 - PhabricatorLiskDAO $object, 519 - $type, 520 - array $xactions) { 521 - 522 - $errors = parent::validateTransaction($object, $type, $xactions); 523 - 524 - foreach ($xactions as $xaction) { 525 - switch ($type) { 526 - case PhabricatorAuditActionConstants::ACTION: 527 - $error = $this->validateAuditAction( 528 - $object, 529 - $type, 530 - $xaction, 531 - $xaction->getNewValue()); 532 - if ($error) { 533 - $errors[] = new PhabricatorApplicationTransactionValidationError( 534 - $type, 535 - pht('Invalid'), 536 - $error, 537 - $xaction); 538 - } 539 - break; 540 - } 541 - } 542 - 543 - return $errors; 544 - } 545 - 546 - private function validateAuditAction( 547 - PhabricatorLiskDAO $object, 548 - $type, 549 - PhabricatorAuditTransaction $xaction, 550 - $action) { 551 - 552 - $can_author_close_key = 'audit.can-author-close-audit'; 553 - $can_author_close = PhabricatorEnv::getEnvConfig($can_author_close_key); 554 - 555 - $actor_is_author = ($object->getAuthorPHID()) && 556 - ($object->getAuthorPHID() == $this->getActingAsPHID()); 557 - 558 - switch ($action) { 559 - case PhabricatorAuditActionConstants::CLOSE: 560 - if (!$actor_is_author) { 561 - return pht( 562 - 'You can not close this audit because you are not the author '. 563 - 'of the commit.'); 564 - } 565 - 566 - if (!$can_author_close) { 567 - return pht( 568 - 'You can not close this audit because "%s" is disabled in '. 569 - 'the Phabricator configuration.', 570 - $can_author_close_key); 571 - } 572 - 573 - break; 574 - } 575 - 576 - return null; 577 - } 578 - 579 419 580 420 protected function supportsSearch() { 581 421 return true;