mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 04:32:43 +01:00
6c9026c33a
Summary: Ref T5873. See PHI14. I don't want to just expose internal transaction data to Conduit by default, since it's often: unstable, unusable, sensitive, or some combination of the three. Instead, let ModularTransactions opt in to providing additional data to Conduit, similar to other infrastructure. If a transaction doesn't, the API returns an empty skeleton for it. This is generally fine since most transactions have no real use cases, and I think we can fill them in as we go. This also probably builds toward T5726, which would likely use the same format, and perhaps simply not publish stuff which did not opt in. This doesn't actually cover "comment" or "inline comment", which are presumably what PHI14 is after, since neither is modular. I'll probably just put a hack in place for this until they can modularize since I suspect modularizing them here is difficult. Test Plan: Ran `transaction.search` on a revision, saw some transactions (title and status transactions) populate with values. Reviewers: chad Reviewed By: chad Maniphest Tasks: T5873 Differential Revision: https://secure.phabricator.com/D18467
69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
<?php
|
|
|
|
final class DifferentialRevisionTitleTransaction
|
|
extends DifferentialRevisionTransactionType {
|
|
|
|
const TRANSACTIONTYPE = 'differential.revision.title';
|
|
const EDITKEY = 'title';
|
|
|
|
public function generateOldValue($object) {
|
|
return $object->getTitle();
|
|
}
|
|
|
|
public function applyInternalEffects($object, $value) {
|
|
$object->setTitle($value);
|
|
}
|
|
|
|
public function getTitle() {
|
|
return pht(
|
|
'%s retitled this revision from %s to %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderOldValue(),
|
|
$this->renderNewValue());
|
|
}
|
|
|
|
public function getTitleForFeed() {
|
|
return pht(
|
|
'%s retitled %s from %s to %s.',
|
|
$this->renderAuthor(),
|
|
$this->renderObject(),
|
|
$this->renderOldValue(),
|
|
$this->renderNewValue());
|
|
}
|
|
|
|
public function validateTransactions($object, array $xactions) {
|
|
$errors = array();
|
|
|
|
if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) {
|
|
$errors[] = $this->newRequiredError(
|
|
pht('Revisions must have a title.'));
|
|
}
|
|
|
|
$max_length = $object->getColumnMaximumByteLength('title');
|
|
foreach ($xactions as $xaction) {
|
|
$new_value = $xaction->getNewValue();
|
|
$new_length = strlen($new_value);
|
|
if ($new_length > $max_length) {
|
|
$errors[] = $this->newInvalidError(
|
|
pht(
|
|
'Revision title is too long: the maximum length of a '.
|
|
'revision title is 255 bytes.'),
|
|
$xaction);
|
|
}
|
|
}
|
|
|
|
return $errors;
|
|
}
|
|
|
|
public function getTransactionTypeForConduit($xaction) {
|
|
return 'title';
|
|
}
|
|
|
|
public function getFieldValuesForConduit($object, $data) {
|
|
return array(
|
|
'old' => $object->getOldValue(),
|
|
'new' => $object->getNewValue(),
|
|
);
|
|
}
|
|
|
|
}
|