Skip to content

Commit 5cb0de1

Browse files
author
epriestley
committed
Restore "Create" transactions
Summary: Ref T10004. This restores "alice created this task." transactions, but in a generic way so we don't have to special case one of the other edits with an old `null` value. In most cases, creating an object now shows only an "alice created this thing." transaction, unless nonempty defaults (usually, policy or spaces) were adjusted. Test Plan: Created pastes, tasks, blogs, packages, and forms. Saw a single "alice created this thing." transaction. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10004 Differential Revision: https://secure.phabricator.com/D14820
1 parent 7168d8e commit 5cb0de1

File tree

9 files changed

+69
-3
lines changed

9 files changed

+69
-3
lines changed

src/applications/maniphest/storage/ManiphestTransaction.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,11 @@ public function getTitle() {
381381
$new = $this->getNewValue();
382382

383383
switch ($this->getTransactionType()) {
384+
case PhabricatorTransactions::TYPE_CREATE:
385+
return pht(
386+
'%s created this task.',
387+
$this->renderHandleLink($author_phid));
388+
384389
case self::TYPE_TITLE:
385390
if ($old === null) {
386391
return pht(

src/applications/owners/storage/PhabricatorOwnersPackageTransaction.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,16 @@ public function shouldHide() {
4747

4848
switch ($this->getTransactionType()) {
4949
case self::TYPE_DESCRIPTION:
50-
return ($old === null);
50+
if ($old === null) {
51+
return true;
52+
}
53+
break;
5154
case self::TYPE_PRIMARY:
5255
// TODO: Eventually, remove these transactions entirely.
5356
return true;
5457
}
58+
59+
return parent::shouldHide();
5560
}
5661

5762
public function getTitle() {
@@ -60,6 +65,10 @@ public function getTitle() {
6065
$author_phid = $this->getAuthorPHID();
6166

6267
switch ($this->getTransactionType()) {
68+
case PhabricatorTransactions::TYPE_CREATE:
69+
return pht(
70+
'%s created this package.',
71+
$this->renderHandleLink($author_phid));
6372
case self::TYPE_NAME:
6473
if ($old === null) {
6574
return pht(

src/applications/paste/storage/PhabricatorPasteTransaction.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ public function shouldHide() {
4141
switch ($this->getTransactionType()) {
4242
case self::TYPE_TITLE:
4343
case self::TYPE_LANGUAGE:
44-
return ($old === null);
44+
if ($old === null) {
45+
return true;
46+
}
47+
break;
4548
}
4649
return parent::shouldHide();
4750
}
@@ -77,6 +80,10 @@ public function getTitle() {
7780

7881
$type = $this->getTransactionType();
7982
switch ($type) {
83+
case PhabricatorTransactions::TYPE_CREATE:
84+
return pht(
85+
'%s created this paste.',
86+
$this->renderHandleLink($author_phid));
8087
case self::TYPE_CONTENT:
8188
if ($old === null) {
8289
return pht(

src/applications/phame/storage/PhameBlogTransaction.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public function shouldHide() {
2424
$old = $this->getOldValue();
2525
switch ($this->getTransactionType()) {
2626
case self::TYPE_DESCRIPTION:
27-
return ($old === null);
27+
if ($old === null) {
28+
return true;
29+
}
2830
}
2931
return parent::shouldHide();
3032
}
@@ -98,6 +100,10 @@ public function getTitle() {
98100

99101
$type = $this->getTransactionType();
100102
switch ($type) {
103+
case PhabricatorTransactions::TYPE_CREATE:
104+
return pht(
105+
'%s created this blog.',
106+
$this->renderHandleLink($author_phid));
101107
case self::TYPE_NAME:
102108
if ($old === null) {
103109
return pht(

src/applications/transactions/constants/PhabricatorTransactions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ final class PhabricatorTransactions extends Phobject {
1313
const TYPE_TOKEN = 'token:give';
1414
const TYPE_INLINESTATE = 'core:inlinestate';
1515
const TYPE_SPACE = 'core:space';
16+
const TYPE_CREATE = 'core:create';
1617

1718
const COLOR_RED = 'red';
1819
const COLOR_ORANGE = 'orange';

src/applications/transactions/editengine/PhabricatorEditEngine.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,12 @@ private function buildEditResponse($object) {
857857
}
858858

859859
$xactions = array();
860+
861+
if ($this->getIsCreate()) {
862+
$xactions[] = id(clone $template)
863+
->setTransactionType(PhabricatorTransactions::TYPE_CREATE);
864+
}
865+
860866
foreach ($submit_fields as $key => $field) {
861867
$field_value = $field->getValueForTransaction();
862868

@@ -1647,6 +1653,12 @@ private function getConduitTransactions(
16471653
}
16481654

16491655
$results = array();
1656+
1657+
if ($this->getIsCreate()) {
1658+
$results[] = id(clone $template)
1659+
->setTransactionType(PhabricatorTransactions::TYPE_CREATE);
1660+
}
1661+
16501662
foreach ($xactions as $xaction) {
16511663
$type = $types[$xaction['type']];
16521664

src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,8 @@ public function getTransactionTypesForObject($object) {
258258
public function getTransactionTypes() {
259259
$types = array();
260260

261+
$types[] = PhabricatorTransactions::TYPE_CREATE;
262+
261263
if ($this->object instanceof PhabricatorSubscribableInterface) {
262264
$types[] = PhabricatorTransactions::TYPE_SUBSCRIBERS;
263265
}
@@ -303,6 +305,8 @@ private function getTransactionOldValue(
303305
PhabricatorLiskDAO $object,
304306
PhabricatorApplicationTransaction $xaction) {
305307
switch ($xaction->getTransactionType()) {
308+
case PhabricatorTransactions::TYPE_CREATE:
309+
return null;
306310
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
307311
return array_values($this->subscribers);
308312
case PhabricatorTransactions::TYPE_VIEW_POLICY:
@@ -371,6 +375,8 @@ private function getTransactionNewValue(
371375
PhabricatorLiskDAO $object,
372376
PhabricatorApplicationTransaction $xaction) {
373377
switch ($xaction->getTransactionType()) {
378+
case PhabricatorTransactions::TYPE_CREATE:
379+
return null;
374380
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
375381
return $this->getPHIDTransactionNewValue($xaction);
376382
case PhabricatorTransactions::TYPE_VIEW_POLICY:
@@ -422,6 +428,8 @@ protected function transactionHasEffect(
422428
PhabricatorApplicationTransaction $xaction) {
423429

424430
switch ($xaction->getTransactionType()) {
431+
case PhabricatorTransactions::TYPE_CREATE:
432+
return true;
425433
case PhabricatorTransactions::TYPE_COMMENT:
426434
return $xaction->hasComment();
427435
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
@@ -484,6 +492,7 @@ private function applyInternalEffects(
484492
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
485493
$field = $this->getCustomFieldForTransaction($object, $xaction);
486494
return $field->applyApplicationTransactionInternalEffects($xaction);
495+
case PhabricatorTransactions::TYPE_CREATE:
487496
case PhabricatorTransactions::TYPE_BUILDABLE:
488497
case PhabricatorTransactions::TYPE_TOKEN:
489498
case PhabricatorTransactions::TYPE_VIEW_POLICY:
@@ -534,6 +543,7 @@ private function applyExternalEffects(
534543
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
535544
$field = $this->getCustomFieldForTransaction($object, $xaction);
536545
return $field->applyApplicationTransactionExternalEffects($xaction);
546+
case PhabricatorTransactions::TYPE_CREATE:
537547
case PhabricatorTransactions::TYPE_EDGE:
538548
case PhabricatorTransactions::TYPE_BUILDABLE:
539549
case PhabricatorTransactions::TYPE_TOKEN:

src/applications/transactions/storage/PhabricatorApplicationTransaction.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ public function shouldHide() {
482482
// essentially never interesting.
483483
if ($this->getIsCreateTransaction()) {
484484
switch ($this->getTransactionType()) {
485+
case PhabricatorTransactions::TYPE_CREATE:
485486
case PhabricatorTransactions::TYPE_VIEW_POLICY:
486487
case PhabricatorTransactions::TYPE_EDIT_POLICY:
487488
case PhabricatorTransactions::TYPE_JOIN_POLICY:
@@ -497,6 +498,7 @@ public function shouldHide() {
497498
if (!strlen($old)) {
498499
return true;
499500
}
501+
break;
500502
}
501503
}
502504

@@ -702,6 +704,10 @@ public function getTitle() {
702704
$new = $this->getNewValue();
703705

704706
switch ($this->getTransactionType()) {
707+
case PhabricatorTransactions::TYPE_CREATE:
708+
return pht(
709+
'%s created this object.',
710+
$this->renderHandleLink($author_phid));
705711
case PhabricatorTransactions::TYPE_COMMENT:
706712
return pht(
707713
'%s added a comment.',
@@ -918,6 +924,11 @@ public function getTitleForFeed() {
918924
$new = $this->getNewValue();
919925

920926
switch ($this->getTransactionType()) {
927+
case PhabricatorTransactions::TYPE_CREATE:
928+
return pht(
929+
'%s created %s.',
930+
$this->renderHandleLink($author_phid),
931+
$this->renderHandleLink($object_phid));
921932
case PhabricatorTransactions::TYPE_COMMENT:
922933
return pht(
923934
'%s added a comment to %s.',
@@ -1119,6 +1130,7 @@ public function getActionStrength() {
11191130
// Make this weaker than TYPE_COMMENT.
11201131
return 0.25;
11211132
}
1133+
11221134
return 1.0;
11231135
}
11241136

src/applications/transactions/storage/PhabricatorEditEngineConfigurationTransaction.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public function getTitle() {
3434

3535
$type = $this->getTransactionType();
3636
switch ($type) {
37+
case PhabricatorTransactions::TYPE_CREATE:
38+
return pht(
39+
'%s created this form configuration.',
40+
$this->renderHandleLink($author_phid));
3741
case self::TYPE_NAME:
3842
if (strlen($old)) {
3943
return pht(

0 commit comments

Comments
 (0)