1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-05 20:31:03 +01:00
phorge-phorge/src/applications/differential/xaction/DifferentialRevisionInlineTransaction.php
epriestley 213e4ec9b5 Add a missing (int) cast to diff IDs for new "transaction.search" method
Summary: These come out of the database as strings (see T12678), force them to integers for the API.

Test Plan: Called `transaction.search`, got integers in JSON instead of strings.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D18476
2017-08-25 07:31:22 -07:00

53 lines
1.5 KiB
PHP

<?php
final class DifferentialRevisionInlineTransaction
extends PhabricatorModularTransactionType {
// NOTE: This class is NOT an actual Differential modular transaction type!
// It does not extend "DifferentialRevisionTransactionType". Some day it
// should, but for now it's just reducing the amount of hackiness around
// supporting inline comments in the "transaction.search" Conduit API method.
const TRANSACTIONTYPE = 'internal.pretend-inline';
public function getTransactionTypeForConduit($xaction) {
return 'inline';
}
public function loadTransactionTypeConduitData(array $xactions) {
$viewer = $this->getViewer();
$changeset_ids = array();
foreach ($xactions as $xaction) {
$changeset_ids[] = $xaction->getComment()->getChangesetID();
}
$changesets = id(new DifferentialChangesetQuery())
->setViewer($viewer)
->withIDs($changeset_ids)
->execute();
$changesets = mpull($changesets, null, 'getID');
return $changesets;
}
public function getFieldValuesForConduit($object, $data) {
$comment = $object->getComment();
$changeset = $data[$comment->getChangesetID()];
$diff = $changeset->getDiff();
return array(
'diff' => array(
'id' => (int)$diff->getID(),
'phid' => $diff->getPHID(),
),
'path' => $changeset->getDisplayFilename(),
'line' => (int)$comment->getLineNumber(),
'length' => (int)($comment->getLineLength() + 1),
'replyToCommentPHID' => $comment->getReplyToCommentPHID(),
);
}
}