@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.

Move Phriction Title transaction to Modular Transactions

Summary: Ref T12625. Moves TYPE_TITLE to modular transaction.

Test Plan: New Document, Edit Document, test validation, verify feed stories.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12625

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

+125 -106
+5 -1
src/__phutil_library_map__.php
··· 4621 4621 'PhrictionDocumentQuery' => 'applications/phriction/query/PhrictionDocumentQuery.php', 4622 4622 'PhrictionDocumentStatus' => 'applications/phriction/constants/PhrictionDocumentStatus.php', 4623 4623 'PhrictionDocumentTitleHeraldField' => 'applications/phriction/herald/PhrictionDocumentTitleHeraldField.php', 4624 + 'PhrictionDocumentTitleTransaction' => 'applications/phriction/xaction/PhrictionDocumentTitleTransaction.php', 4625 + 'PhrictionDocumentTransactionType' => 'applications/phriction/xaction/PhrictionDocumentTransactionType.php', 4624 4626 'PhrictionEditConduitAPIMethod' => 'applications/phriction/conduit/PhrictionEditConduitAPIMethod.php', 4625 4627 'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php', 4626 4628 'PhrictionHistoryConduitAPIMethod' => 'applications/phriction/conduit/PhrictionHistoryConduitAPIMethod.php', ··· 10257 10259 'PhrictionDocumentQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 10258 10260 'PhrictionDocumentStatus' => 'PhrictionConstants', 10259 10261 'PhrictionDocumentTitleHeraldField' => 'PhrictionDocumentHeraldField', 10262 + 'PhrictionDocumentTitleTransaction' => 'PhrictionDocumentTransactionType', 10263 + 'PhrictionDocumentTransactionType' => 'PhabricatorModularTransactionType', 10260 10264 'PhrictionEditConduitAPIMethod' => 'PhrictionConduitAPIMethod', 10261 10265 'PhrictionEditController' => 'PhrictionController', 10262 10266 'PhrictionHistoryConduitAPIMethod' => 'PhrictionConduitAPIMethod', ··· 10270 10274 'PhrictionReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 10271 10275 'PhrictionSchemaSpec' => 'PhabricatorConfigSchemaSpec', 10272 10276 'PhrictionSearchEngine' => 'PhabricatorApplicationSearchEngine', 10273 - 'PhrictionTransaction' => 'PhabricatorApplicationTransaction', 10277 + 'PhrictionTransaction' => 'PhabricatorModularTransaction', 10274 10278 'PhrictionTransactionComment' => 'PhabricatorApplicationTransactionComment', 10275 10279 'PhrictionTransactionEditor' => 'PhabricatorApplicationTransactionEditor', 10276 10280 'PhrictionTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
+1 -1
src/applications/phriction/conduit/PhrictionCreateConduitAPIMethod.php
··· 47 47 48 48 $xactions = array(); 49 49 $xactions[] = id(new PhrictionTransaction()) 50 - ->setTransactionType(PhrictionTransaction::TYPE_TITLE) 50 + ->setTransactionType(PhrictionDocumentTitleTransaction::TRANSACTIONTYPE) 51 51 ->setNewValue($request->getValue('title')); 52 52 $xactions[] = id(new PhrictionTransaction()) 53 53 ->setTransactionType(PhrictionTransaction::TYPE_CONTENT)
+1 -1
src/applications/phriction/conduit/PhrictionEditConduitAPIMethod.php
··· 42 42 43 43 $xactions = array(); 44 44 $xactions[] = id(new PhrictionTransaction()) 45 - ->setTransactionType(PhrictionTransaction::TYPE_TITLE) 45 + ->setTransactionType(PhrictionDocumentTitleTransaction::TRANSACTIONTYPE) 46 46 ->setNewValue($request->getValue('title')); 47 47 $xactions[] = id(new PhrictionTransaction()) 48 48 ->setTransactionType(PhrictionTransaction::TYPE_CONTENT)
+3 -2
src/applications/phriction/controller/PhrictionEditController.php
··· 133 133 134 134 $xactions = array(); 135 135 $xactions[] = id(new PhrictionTransaction()) 136 - ->setTransactionType(PhrictionTransaction::TYPE_TITLE) 136 + ->setTransactionType(PhrictionDocumentTitleTransaction::TRANSACTIONTYPE) 137 137 ->setNewValue($title); 138 138 $xactions[] = id(new PhrictionTransaction()) 139 139 ->setTransactionType(PhrictionTransaction::TYPE_CONTENT) ··· 174 174 } catch (PhabricatorApplicationTransactionValidationException $ex) { 175 175 $validation_exception = $ex; 176 176 $e_title = nonempty( 177 - $ex->getShortMessage(PhrictionTransaction::TYPE_TITLE), 177 + $ex->getShortMessage( 178 + PhrictionDocumentTitleTransaction::TRANSACTIONTYPE), 178 179 true); 179 180 $e_content = nonempty( 180 181 $ex->getShortMessage(PhrictionTransaction::TYPE_CONTENT),
+6 -40
src/applications/phriction/editor/PhrictionTransactionEditor.php
··· 29 29 return $this; 30 30 } 31 31 32 - private function getOldContent() { 32 + public function getOldContent() { 33 33 return $this->oldContent; 34 34 } 35 35 ··· 38 38 return $this; 39 39 } 40 40 41 - private function getNewContent() { 41 + public function getNewContent() { 42 42 return $this->newContent; 43 43 } 44 44 ··· 80 80 public function getTransactionTypes() { 81 81 $types = parent::getTransactionTypes(); 82 82 83 - $types[] = PhrictionTransaction::TYPE_TITLE; 84 83 $types[] = PhrictionTransaction::TYPE_CONTENT; 85 84 $types[] = PhrictionTransaction::TYPE_DELETE; 86 85 $types[] = PhrictionTransaction::TYPE_MOVE_TO; ··· 99 98 PhabricatorApplicationTransaction $xaction) { 100 99 101 100 switch ($xaction->getTransactionType()) { 102 - case PhrictionTransaction::TYPE_TITLE: 103 - if ($this->getIsNewObject()) { 104 - return null; 105 - } 106 - return $this->getOldContent()->getTitle(); 107 101 case PhrictionTransaction::TYPE_CONTENT: 108 102 if ($this->getIsNewObject()) { 109 103 return null; ··· 121 115 PhabricatorApplicationTransaction $xaction) { 122 116 123 117 switch ($xaction->getTransactionType()) { 124 - case PhrictionTransaction::TYPE_TITLE: 125 118 case PhrictionTransaction::TYPE_CONTENT: 126 119 case PhrictionTransaction::TYPE_DELETE: 127 120 return $xaction->getNewValue(); ··· 154 147 155 148 foreach ($xactions as $xaction) { 156 149 switch ($xaction->getTransactionType()) { 157 - case PhrictionTransaction::TYPE_TITLE: 150 + case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 158 151 case PhrictionTransaction::TYPE_CONTENT: 159 152 case PhrictionTransaction::TYPE_DELETE: 160 153 case PhrictionTransaction::TYPE_MOVE_TO: ··· 178 171 PhabricatorApplicationTransaction $xaction) { 179 172 180 173 switch ($xaction->getTransactionType()) { 181 - case PhrictionTransaction::TYPE_TITLE: 182 174 case PhrictionTransaction::TYPE_CONTENT: 183 175 case PhrictionTransaction::TYPE_MOVE_TO: 184 176 $object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS); ··· 232 224 PhabricatorApplicationTransaction $xaction) { 233 225 234 226 switch ($xaction->getTransactionType()) { 235 - case PhrictionTransaction::TYPE_TITLE: 236 - $this->getNewContent()->setTitle($xaction->getNewValue()); 237 - break; 238 227 case PhrictionTransaction::TYPE_CONTENT: 239 228 $this->getNewContent()->setContent($xaction->getNewValue()); 240 229 break; ··· 270 259 $save_content = false; 271 260 foreach ($xactions as $xaction) { 272 261 switch ($xaction->getTransactionType()) { 273 - case PhrictionTransaction::TYPE_TITLE: 262 + case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 274 263 case PhrictionTransaction::TYPE_CONTENT: 275 264 case PhrictionTransaction::TYPE_DELETE: 276 265 case PhrictionTransaction::TYPE_MOVE_AWAY: ··· 312 301 $slug); 313 302 $stub_xactions = array(); 314 303 $stub_xactions[] = id(new PhrictionTransaction()) 315 - ->setTransactionType(PhrictionTransaction::TYPE_TITLE) 304 + ->setTransactionType( 305 + PhrictionDocumentTitleTransaction::TRANSACTIONTYPE) 316 306 ->setNewValue(PhabricatorSlug::getDefaultTitle($slug)) 317 307 ->setMetadataValue('stub:create:phid', $object->getPHID()); 318 308 $stub_xactions[] = id(new PhrictionTransaction()) ··· 477 467 478 468 foreach ($xactions as $xaction) { 479 469 switch ($type) { 480 - case PhrictionTransaction::TYPE_TITLE: 481 - $title = $object->getContent()->getTitle(); 482 - $missing = $this->validateIsEmptyTextField( 483 - $title, 484 - $xactions); 485 - 486 - if ($missing) { 487 - $error = new PhabricatorApplicationTransactionValidationError( 488 - $type, 489 - pht('Required'), 490 - pht('Document title is required.'), 491 - nonempty(last($xactions), null)); 492 - 493 - $error->setIsMissingFieldError(true); 494 - $errors[] = $error; 495 - } else if ($this->getProcessContentVersionError()) { 496 - $error = $this->validateContentVersion($object, $type, $xaction); 497 - if ($error) { 498 - $this->setProcessContentVersionError(false); 499 - $errors[] = $error; 500 - } 501 - } 502 - break; 503 - 504 470 case PhrictionTransaction::TYPE_CONTENT: 505 471 if ($xaction->getMetadataValue('stub:create:phid')) { 506 472 continue;
+9 -59
src/applications/phriction/storage/PhrictionTransaction.php
··· 1 1 <?php 2 2 3 3 final class PhrictionTransaction 4 - extends PhabricatorApplicationTransaction { 4 + extends PhabricatorModularTransaction { 5 5 6 - const TYPE_TITLE = 'title'; 7 6 const TYPE_CONTENT = 'content'; 8 7 const TYPE_DELETE = 'delete'; 9 8 const TYPE_MOVE_TO = 'move-to'; ··· 27 26 return new PhrictionTransactionComment(); 28 27 } 29 28 29 + public function getBaseTransactionClass() { 30 + return 'PhrictionDocumentTransactionType'; 31 + } 32 + 30 33 public function getRequiredHandlePHIDs() { 31 34 $phids = parent::getRequiredHandlePHIDs(); 32 35 $new = $this->getNewValue(); ··· 35 38 case self::TYPE_MOVE_AWAY: 36 39 $phids[] = $new['phid']; 37 40 break; 38 - case self::TYPE_TITLE: 41 + case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 39 42 if ($this->getMetadataValue('stub:create:phid')) { 40 43 $phids[] = $this->getMetadataValue('stub:create:phid'); 41 44 } 42 45 break; 43 46 } 44 47 45 - 46 48 return $phids; 47 49 } 48 50 ··· 77 79 case self::TYPE_MOVE_TO: 78 80 case self::TYPE_MOVE_AWAY: 79 81 return true; 80 - case self::TYPE_TITLE: 82 + case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 81 83 return $this->getMetadataValue('stub:create:phid', false); 82 84 } 83 85 return parent::shouldHideForMail($xactions); ··· 88 90 case self::TYPE_MOVE_TO: 89 91 case self::TYPE_MOVE_AWAY: 90 92 return true; 91 - case self::TYPE_TITLE: 93 + case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 92 94 return $this->getMetadataValue('stub:create:phid', false); 93 95 } 94 96 return parent::shouldHideForFeed(); ··· 96 98 97 99 public function getActionStrength() { 98 100 switch ($this->getTransactionType()) { 99 - case self::TYPE_TITLE: 100 - return 1.4; 101 101 case self::TYPE_CONTENT: 102 102 return 1.3; 103 103 case self::TYPE_DELETE: ··· 115 115 $new = $this->getNewValue(); 116 116 117 117 switch ($this->getTransactionType()) { 118 - case self::TYPE_TITLE: 119 - if ($old === null) { 120 - if ($this->getMetadataValue('stub:create:phid')) { 121 - return pht('Stubbed'); 122 - } else { 123 - return pht('Created'); 124 - } 125 - } 126 - 127 - return pht('Retitled'); 128 - 129 118 case self::TYPE_CONTENT: 130 119 return pht('Edited'); 131 - 132 120 case self::TYPE_DELETE: 133 121 return pht('Deleted'); 134 - 135 122 case self::TYPE_MOVE_TO: 136 123 return pht('Moved'); 137 - 138 124 case self::TYPE_MOVE_AWAY: 139 125 return pht('Moved Away'); 140 - 141 126 } 142 127 143 128 return parent::getActionName(); ··· 148 133 $new = $this->getNewValue(); 149 134 150 135 switch ($this->getTransactionType()) { 151 - case self::TYPE_TITLE: 152 136 case self::TYPE_CONTENT: 153 137 return 'fa-pencil'; 154 138 case self::TYPE_DELETE: ··· 169 153 $new = $this->getNewValue(); 170 154 171 155 switch ($this->getTransactionType()) { 172 - case self::TYPE_TITLE: 173 - if ($old === null) { 174 - if ($this->getMetadataValue('stub:create:phid')) { 175 - return pht( 176 - '%s stubbed out this document when creating %s.', 177 - $this->renderHandleLink($author_phid), 178 - $this->renderHandleLink( 179 - $this->getMetadataValue('stub:create:phid'))); 180 - } else { 181 - return pht( 182 - '%s created this document.', 183 - $this->renderHandleLink($author_phid)); 184 - } 185 - } 186 - return pht( 187 - '%s changed the title from "%s" to "%s".', 188 - $this->renderHandleLink($author_phid), 189 - $old, 190 - $new); 191 - 192 156 case self::TYPE_CONTENT: 193 157 return pht( 194 158 '%s edited the document content.', ··· 224 188 $new = $this->getNewValue(); 225 189 226 190 switch ($this->getTransactionType()) { 227 - case self::TYPE_TITLE: 228 - if ($old === null) { 229 - return pht( 230 - '%s created %s.', 231 - $this->renderHandleLink($author_phid), 232 - $this->renderHandleLink($object_phid)); 233 - } 234 - 235 - return pht( 236 - '%s renamed %s from "%s" to "%s".', 237 - $this->renderHandleLink($author_phid), 238 - $this->renderHandleLink($object_phid), 239 - $old, 240 - $new); 241 191 242 192 case self::TYPE_CONTENT: 243 193 return pht( ··· 273 223 public function getMailTags() { 274 224 $tags = array(); 275 225 switch ($this->getTransactionType()) { 276 - case self::TYPE_TITLE: 226 + case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 277 227 $tags[] = self::MAILTAG_TITLE; 278 228 break; 279 229 case self::TYPE_CONTENT:
+94
src/applications/phriction/xaction/PhrictionDocumentTitleTransaction.php
··· 1 + <?php 2 + 3 + final class PhrictionDocumentTitleTransaction 4 + extends PhrictionDocumentTransactionType { 5 + 6 + const TRANSACTIONTYPE = 'title'; 7 + 8 + public function generateOldValue($object) { 9 + if ($this->isNewObject()) { 10 + return null; 11 + } 12 + return $this->getEditor()->getOldContent()->getTitle(); 13 + } 14 + 15 + public function applyInternalEffects($object, $value) { 16 + $object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS); 17 + $this->getEditor()->getNewContent()->setTitle($value); 18 + } 19 + 20 + public function getActionStrength() { 21 + return 1.4; 22 + } 23 + 24 + public function getActionName() { 25 + $old = $this->getOldValue(); 26 + $new = $this->getNewValue(); 27 + 28 + if ($old === null) { 29 + if ($this->getMetadataValue('stub:create:phid')) { 30 + return pht('Stubbed'); 31 + } else { 32 + return pht('Created'); 33 + } 34 + } 35 + return pht('Retitled'); 36 + } 37 + 38 + public function getTitle() { 39 + $old = $this->getOldValue(); 40 + $new = $this->getNewValue(); 41 + 42 + if ($old === null) { 43 + if ($this->getMetadataValue('stub:create:phid')) { 44 + return pht( 45 + '%s stubbed out this document when creating %s.', 46 + $this->renderAuthor(), 47 + $this->renderHandleLink( 48 + $this->getMetadataValue('stub:create:phid'))); 49 + } else { 50 + return pht( 51 + '%s created this document.', 52 + $this->renderAuthor()); 53 + } 54 + } 55 + 56 + return pht( 57 + '%s changed the title from %s to %s.', 58 + $this->renderAuthor(), 59 + $this->renderOldValue(), 60 + $this->renderNewValue()); 61 + } 62 + 63 + public function getTitleForFeed() { 64 + $old = $this->getOldValue(); 65 + $new = $this->getNewValue(); 66 + 67 + if ($old === null) { 68 + return pht( 69 + '%s created %s.', 70 + $this->renderAuthor(), 71 + $this->renderObject()); 72 + } 73 + 74 + return pht( 75 + '%s renamed %s from %s to %s.', 76 + $this->renderAuthor(), 77 + $this->renderObject(), 78 + $this->renderOldValue(), 79 + $this->renderNewValue()); 80 + } 81 + 82 + public function validateTransactions($object, array $xactions) { 83 + $errors = array(); 84 + 85 + $title = $object->getContent()->getTitle(); 86 + if ($this->isEmptyTextTransaction($title, $xactions)) { 87 + $errors[] = $this->newRequiredError( 88 + pht('Documents must have a title.')); 89 + } 90 + 91 + return $errors; 92 + } 93 + 94 + }
+4
src/applications/phriction/xaction/PhrictionDocumentTransactionType.php
··· 1 + <?php 2 + 3 + abstract class PhrictionDocumentTransactionType 4 + extends PhabricatorModularTransactionType {}
+2 -2
src/applications/transactions/storage/PhabricatorModularTransaction.php
··· 160 160 return parent::attachViewer($viewer); 161 161 } 162 162 163 - final public function hasChangeDetails() { 163 + /* final */ public function hasChangeDetails() { 164 164 if ($this->getTransactionImplementation()->hasChangeDetailView()) { 165 165 return true; 166 166 } ··· 168 168 return parent::hasChangeDetails(); 169 169 } 170 170 171 - final public function renderChangeDetails(PhabricatorUser $viewer) { 171 + /* final */ public function renderChangeDetails(PhabricatorUser $viewer) { 172 172 $impl = $this->getTransactionImplementation(); 173 173 $impl->setViewer($viewer); 174 174 $view = $impl->newChangeDetailView();