1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 23:01:04 +01:00

Fix an issue with "Auditors:" where an edge edit was used as a PHID list

Summary:
See <https://discourse.phabricator-community.org/t/runtimeexception-during-import-of-commit/3801>. When importing commits with "Auditors:", a raw transaction new value (with an edge edit map using a "+" key) may be passed as an unmentionable PHID list.

Instead, pass an actual PHID list.

Test Plan:
  - Pushed a commit with "Auditors: duck".
  - Ran daemons.
    - Before patch: umentionable PHID exception.
    - After patch: clean commit import.
  - Verified "duck" was added as an auditor.

Differential Revision: https://secure.phabricator.com/D21181
This commit is contained in:
epriestley 2020-04-28 05:42:18 -07:00
parent befeb17f6f
commit a7b2327c34

View file

@ -232,14 +232,22 @@ final class PhabricatorAuditEditor
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
$auditors_type = DiffusionCommitAuditorsTransaction::TRANSACTIONTYPE;
$xactions = parent::expandTransaction($object, $xaction);
switch ($xaction->getTransactionType()) {
case PhabricatorAuditTransaction::TYPE_COMMIT:
$request = $this->createAuditRequestTransactionFromCommitMessage(
$phids = $this->getAuditRequestTransactionPHIDsFromCommitMessage(
$object);
if ($request) {
$xactions[] = $request;
$this->addUnmentionablePHIDs($request->getNewValue());
if ($phids) {
$xactions[] = $object->getApplicationTransactionTemplate()
->setTransactionType($auditors_type)
->setNewValue(
array(
'+' => array_fuse($phids),
));
$this->addUnmentionablePHIDs($phids);
}
break;
default:
@ -268,7 +276,7 @@ final class PhabricatorAuditEditor
return $xactions;
}
private function createAuditRequestTransactionFromCommitMessage(
private function getAuditRequestTransactionPHIDsFromCommitMessage(
PhabricatorRepositoryCommit $commit) {
$actor = $this->getActor();
@ -297,12 +305,7 @@ final class PhabricatorAuditEditor
return array();
}
return $commit->getApplicationTransactionTemplate()
->setTransactionType(DiffusionCommitAuditorsTransaction::TRANSACTIONTYPE)
->setNewValue(
array(
'+' => array_fuse($phids),
));
return $phids;
}
protected function sortTransactions(array $xactions) {