@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 internal document/content references from IDs to PHIDs

Summary:
Ref T13077. This is mostly just a small cleanup change, even though the actual change is large.

We currently reference content and document objects from one another with `contentID` and `documentID`, but this means that `contentID` must be nullable. Switching to PHIDs allows the column to be non-nullable.

This also supports reorienting some current and future transactions around PHIDs, which is preferable for the API. In particular, I'm adding a "publish version X" transaction soon, and would rather callers pass a PHID than an ID or version number, since this will make the API more consistent and powerful.

Today, `contentID` gets used as a cheaty way to order documents by (content) edit time. Since PHIDs aren't orderable and stuff is going to become actually-revertible soon, replace this with an epoch timestamp.

Test Plan:
- Created, edited, moved, retitled, and deleted Phriction documents.
- Grepped for `documentID` and `contentID`.
- This probably breaks //something// but I'll be in this code for a bit and am likely to catch whatever breaks.

Reviewers: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13077

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

+183 -122
+2
resources/sql/autopatches/20180828.phriction.01.contentphid.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phriction.phriction_document 2 + ADD contentPHID VARBINARY(64) NOT NULL;
+2
resources/sql/autopatches/20180828.phriction.02.documentphid.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phriction.phriction_content 2 + ADD documentPHID VARBINARY(64) NOT NULL;
+2
resources/sql/autopatches/20180828.phriction.03.editedepoch.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phriction.phriction_document 2 + ADD editedEpoch INT UNSIGNED NOT NULL;
+57
resources/sql/autopatches/20180828.phriction.04.migrate.php
··· 1 + <?php 2 + 3 + // Update the PhrictionDocument and PhrictionContent tables to refer to one 4 + // another by PHID instead of by ID. 5 + 6 + $document_table = new PhrictionDocument(); 7 + $content_table = new PhrictionContent(); 8 + 9 + $conn = $document_table->establishConnection('w'); 10 + 11 + $document_iterator = new LiskRawMigrationIterator( 12 + $conn, 13 + $document_table->getTableName()); 14 + foreach ($document_iterator as $row) { 15 + $content_id = $row['contentID']; 16 + 17 + $content_row = queryfx_one( 18 + $conn, 19 + 'SELECT phid, dateCreated FROM %T WHERE id = %d', 20 + $content_table->getTableName(), 21 + $content_id); 22 + 23 + if (!$content_row) { 24 + continue; 25 + } 26 + 27 + queryfx( 28 + $conn, 29 + 'UPDATE %T SET contentPHID = %s, editedEpoch = %d WHERE id = %d', 30 + $document_table->getTableName(), 31 + $content_row['phid'], 32 + $content_row['dateCreated'], 33 + $row['id']); 34 + } 35 + 36 + $content_iterator = new LiskRawMigrationIterator( 37 + $conn, 38 + $content_table->getTableName()); 39 + foreach ($content_iterator as $row) { 40 + $document_id = $row['documentID']; 41 + 42 + $document_row = queryfx_one( 43 + $conn, 44 + 'SELECT phid FROM %T WHERE id = %d', 45 + $document_table->getTableName(), 46 + $document_id); 47 + if (!$document_row) { 48 + continue; 49 + } 50 + 51 + queryfx( 52 + $conn, 53 + 'UPDATE %T SET documentPHID = %s WHERE id = %d', 54 + $content_table->getTableName(), 55 + $document_row['phid'], 56 + $row['id']); 57 + }
+2
resources/sql/autopatches/20180828.phriction.05.contentid.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phriction.phriction_document 2 + DROP contentID;
+2
resources/sql/autopatches/20180828.phriction.06.documentid.sql
··· 1 + ALTER TABLE {$NAMESPACE}_phriction.phriction_content 2 + DROP documentID;
+7 -5
src/__phutil_library_map__.php
··· 5036 5036 'PhrictionDocumentTitleHeraldField' => 'applications/phriction/herald/PhrictionDocumentTitleHeraldField.php', 5037 5037 'PhrictionDocumentTitleTransaction' => 'applications/phriction/xaction/PhrictionDocumentTitleTransaction.php', 5038 5038 'PhrictionDocumentTransactionType' => 'applications/phriction/xaction/PhrictionDocumentTransactionType.php', 5039 + 'PhrictionDocumentVersionTransaction' => 'applications/phriction/xaction/PhrictionDocumentVersionTransaction.php', 5039 5040 'PhrictionEditConduitAPIMethod' => 'applications/phriction/conduit/PhrictionEditConduitAPIMethod.php', 5040 5041 'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php', 5041 5042 'PhrictionHistoryConduitAPIMethod' => 'applications/phriction/conduit/PhrictionHistoryConduitAPIMethod.php', ··· 11129 11130 ), 11130 11131 'PhrictionDocumentAuthorHeraldField' => 'PhrictionDocumentHeraldField', 11131 11132 'PhrictionDocumentContentHeraldField' => 'PhrictionDocumentHeraldField', 11132 - 'PhrictionDocumentContentTransaction' => 'PhrictionDocumentTransactionType', 11133 + 'PhrictionDocumentContentTransaction' => 'PhrictionDocumentVersionTransaction', 11133 11134 'PhrictionDocumentController' => 'PhrictionController', 11134 11135 'PhrictionDocumentDatasource' => 'PhabricatorTypeaheadDatasource', 11135 - 'PhrictionDocumentDeleteTransaction' => 'PhrictionDocumentTransactionType', 11136 + 'PhrictionDocumentDeleteTransaction' => 'PhrictionDocumentVersionTransaction', 11136 11137 'PhrictionDocumentFerretEngine' => 'PhabricatorFerretEngine', 11137 11138 'PhrictionDocumentFulltextEngine' => 'PhabricatorFulltextEngine', 11138 11139 'PhrictionDocumentHeraldAdapter' => 'HeraldAdapter', 11139 11140 'PhrictionDocumentHeraldField' => 'HeraldField', 11140 11141 'PhrictionDocumentHeraldFieldGroup' => 'HeraldFieldGroup', 11141 - 'PhrictionDocumentMoveAwayTransaction' => 'PhrictionDocumentTransactionType', 11142 - 'PhrictionDocumentMoveToTransaction' => 'PhrictionDocumentTransactionType', 11142 + 'PhrictionDocumentMoveAwayTransaction' => 'PhrictionDocumentVersionTransaction', 11143 + 'PhrictionDocumentMoveToTransaction' => 'PhrictionDocumentVersionTransaction', 11143 11144 'PhrictionDocumentPHIDType' => 'PhabricatorPHIDType', 11144 11145 'PhrictionDocumentPathHeraldField' => 'PhrictionDocumentHeraldField', 11145 11146 'PhrictionDocumentPolicyCodex' => 'PhabricatorPolicyCodex', ··· 11148 11149 'PhrictionDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine', 11149 11150 'PhrictionDocumentStatus' => 'PhabricatorObjectStatus', 11150 11151 'PhrictionDocumentTitleHeraldField' => 'PhrictionDocumentHeraldField', 11151 - 'PhrictionDocumentTitleTransaction' => 'PhrictionDocumentTransactionType', 11152 + 'PhrictionDocumentTitleTransaction' => 'PhrictionDocumentVersionTransaction', 11152 11153 'PhrictionDocumentTransactionType' => 'PhabricatorModularTransactionType', 11154 + 'PhrictionDocumentVersionTransaction' => 'PhrictionDocumentTransactionType', 11153 11155 'PhrictionEditConduitAPIMethod' => 'PhrictionConduitAPIMethod', 11154 11156 'PhrictionEditController' => 'PhrictionController', 11155 11157 'PhrictionHistoryConduitAPIMethod' => 'PhrictionConduitAPIMethod',
+4 -3
src/applications/phriction/controller/PhrictionDiffController.php
··· 65 65 66 66 $slug = $document->getSlug(); 67 67 68 - $revert_l = $this->renderRevertButton($content_l, $current); 69 - $revert_r = $this->renderRevertButton($content_r, $current); 68 + $revert_l = $this->renderRevertButton($document, $content_l, $current); 69 + $revert_r = $this->renderRevertButton($document, $content_r, $current); 70 70 71 71 $crumbs = $this->buildApplicationCrumbs(); 72 72 $crumb_views = $this->renderBreadcrumbs($slug); ··· 179 179 } 180 180 181 181 private function renderRevertButton( 182 + PhrictionDocument $document, 182 183 PhrictionContent $content, 183 184 PhrictionContent $current) { 184 185 185 - $document_id = $content->getDocumentID(); 186 + $document_id = $document->getID(); 186 187 $version = $content->getVersion(); 187 188 188 189 $hidden_statuses = array(
+1 -1
src/applications/phriction/controller/PhrictionDocumentController.php
··· 78 78 return new Aphront404Response(); 79 79 } 80 80 81 - if ($content->getID() != $document->getContentID()) { 81 + if ($content->getPHID() != $document->getContentPHID()) { 82 82 $version_note = id(new PHUIInfoView()) 83 83 ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 84 84 ->appendChild(
+1 -1
src/applications/phriction/controller/PhrictionHistoryController.php
··· 52 52 } 53 53 54 54 $vs_head = null; 55 - if ($content->getID() != $document->getContentID()) { 55 + if ($content->getPHID() != $document->getContentPHID()) { 56 56 $vs_head = $diff_uri 57 57 ->alter('l', $content->getVersion()) 58 58 ->alter('r', $current->getVersion());
+38 -49
src/applications/phriction/editor/PhrictionTransactionEditor.php
··· 93 93 return $types; 94 94 } 95 95 96 - protected function shouldApplyInitialEffects( 96 + protected function expandTransactions( 97 97 PhabricatorLiskDAO $object, 98 98 array $xactions) { 99 99 100 - foreach ($xactions as $xaction) { 101 - switch ($xaction->getTransactionType()) { 102 - case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 103 - case PhrictionDocumentContentTransaction::TRANSACTIONTYPE: 104 - case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE: 105 - case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: 106 - case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: 107 - return true; 108 - } 109 - } 110 - return parent::shouldApplyInitialEffects($object, $xactions); 111 - } 100 + $this->setOldContent($object->getContent()); 112 101 113 - protected function applyInitialEffects( 114 - PhabricatorLiskDAO $object, 115 - array $xactions) { 116 - 117 - $this->setOldContent($object->getContent()); 118 - $this->setNewContent($this->buildNewContentTemplate($object)); 102 + return parent::expandTransactions($object, $xactions); 119 103 } 120 104 121 105 protected function expandTransaction( ··· 148 132 break; 149 133 default: 150 134 break; 151 - 152 135 } 153 136 154 137 return $xactions; ··· 158 141 PhabricatorLiskDAO $object, 159 142 array $xactions) { 160 143 161 - $save_content = false; 162 - foreach ($xactions as $xaction) { 163 - switch ($xaction->getTransactionType()) { 164 - case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE: 165 - case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE: 166 - case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE: 167 - case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE: 168 - case PhrictionDocumentContentTransaction::TRANSACTIONTYPE: 169 - $save_content = true; 170 - break; 171 - default: 172 - break; 173 - } 174 - } 175 - 176 - if ($save_content) { 177 - $content = $this->getNewContent(); 178 - $content->setDocumentID($object->getID()); 179 - $content->save(); 144 + if ($this->hasNewDocumentContent()) { 145 + $content = $this->getNewDocumentContent($object); 180 146 181 - $object->setContentID($content->getID()); 182 - $object->save(); 183 - $object->attachContent($content); 147 + $content 148 + ->setDocumentPHID($object->getPHID()) 149 + ->save(); 184 150 } 185 151 186 152 if ($this->getIsNewObject() && !$this->getSkipAncestorCheck()) { ··· 535 501 ->setDocument($object); 536 502 } 537 503 538 - private function buildNewContentTemplate( 539 - PhrictionDocument $document) { 504 + private function hasNewDocumentContent() { 505 + return (bool)$this->newContent; 506 + } 507 + 508 + public function getNewDocumentContent(PhrictionDocument $document) { 509 + if (!$this->hasNewDocumentContent()) { 510 + $content = $this->newDocumentContent($document); 511 + 512 + // Generate a PHID now so we can populate "contentPHID" before saving 513 + // the document to the database: the column is not nullable so we need 514 + // a value. 515 + $content_phid = $content->generatePHID(); 516 + 517 + $content->setPHID($content_phid); 518 + 519 + $document->setContentPHID($content_phid); 520 + $document->attachContent($content); 521 + $document->setEditedEpoch(PhabricatorTime::getNow()); 522 + 523 + $this->newContent = $content; 524 + } 525 + 526 + return $this->newContent; 527 + } 540 528 541 - $new_content = id(new PhrictionContent()) 529 + private function newDocumentContent(PhrictionDocument $document) { 530 + $content = id(new PhrictionContent()) 542 531 ->setSlug($document->getSlug()) 543 - ->setAuthorPHID($this->getActor()->getPHID()) 532 + ->setAuthorPHID($this->getActingAsPHID()) 544 533 ->setChangeType(PhrictionChangeType::CHANGE_EDIT) 545 534 ->setTitle($this->getOldContent()->getTitle()) 546 535 ->setContent($this->getOldContent()->getContent()) 547 536 ->setDescription(''); 548 537 549 538 if (strlen($this->getDescription())) { 550 - $new_content->setDescription($this->getDescription()); 539 + $content->setDescription($this->getDescription()); 551 540 } 552 541 553 - $new_content->setVersion($this->getOldContent()->getVersion() + 1); 542 + $content->setVersion($this->getOldContent()->getVersion() + 1); 554 543 555 - return $new_content; 544 + return $content; 556 545 } 557 546 558 547 protected function getCustomWorkerState() {
+6 -6
src/applications/phriction/query/PhrictionContentQuery.php
··· 76 76 if ($this->shouldJoinDocumentTable()) { 77 77 $joins[] = qsprintf( 78 78 $conn, 79 - 'JOIN %T d ON d.id = c.documentID', 79 + 'JOIN %T d ON d.phid = c.documentPHID', 80 80 id(new PhrictionDocument())->getTableName()); 81 81 } 82 82 ··· 84 84 } 85 85 86 86 protected function willFilterPage(array $contents) { 87 - $document_ids = mpull($contents, 'getDocumentID'); 87 + $document_phids = mpull($contents, 'getDocumentPHID'); 88 88 89 89 $documents = id(new PhrictionDocumentQuery()) 90 90 ->setViewer($this->getViewer()) 91 91 ->setParentQuery($this) 92 - ->withIDs($document_ids) 92 + ->withPHIDs($document_phids) 93 93 ->execute(); 94 - $documents = mpull($documents, null, 'getID'); 94 + $documents = mpull($documents, null, 'getPHID'); 95 95 96 96 foreach ($contents as $key => $content) { 97 - $document_id = $content->getDocumentID(); 97 + $document_phid = $content->getDocumentPHID(); 98 98 99 - $document = idx($documents, $document_id); 99 + $document = idx($documents, $document_phid); 100 100 if (!$document) { 101 101 unset($contents[$key]); 102 102 $this->didRejectResult($content);
+10 -10
src/applications/phriction/query/PhrictionDocumentQuery.php
··· 151 151 $contents = id(new PhrictionContentQuery()) 152 152 ->setViewer($this->getViewer()) 153 153 ->setParentQuery($this) 154 - ->withIDs(mpull($documents, 'getContentID')) 154 + ->withPHIDs(mpull($documents, 'getContentPHID')) 155 155 ->execute(); 156 - $contents = mpull($contents, null, 'getID'); 156 + $contents = mpull($contents, null, 'getPHID'); 157 157 158 158 foreach ($documents as $key => $document) { 159 - $content_id = $document->getContentID(); 160 - if (empty($contents[$content_id])) { 159 + $content_phid = $document->getContentPHID(); 160 + if (empty($contents[$content_phid])) { 161 161 unset($documents[$key]); 162 162 continue; 163 163 } 164 - $document->attachContent($contents[$content_id]); 164 + $document->attachContent($contents[$content_phid]); 165 165 } 166 166 } 167 167 ··· 175 175 $content_dao = new PhrictionContent(); 176 176 $joins[] = qsprintf( 177 177 $conn, 178 - 'JOIN %T c ON d.contentID = c.id', 178 + 'JOIN %T c ON d.contentPHID = c.phid', 179 179 $content_dao->getTableName()); 180 180 } 181 181 ··· 321 321 public function getBuiltinOrders() { 322 322 return parent::getBuiltinOrders() + array( 323 323 self::ORDER_HIERARCHY => array( 324 - 'vector' => array('depth', 'title', 'updated'), 324 + 'vector' => array('depth', 'title', 'updated', 'id'), 325 325 'name' => pht('Hierarchy'), 326 326 ), 327 327 ); ··· 343 343 ), 344 344 'updated' => array( 345 345 'table' => 'd', 346 - 'column' => 'contentID', 346 + 'column' => 'editedEpoch', 347 347 'type' => 'int', 348 - 'unique' => true, 348 + 'unique' => false, 349 349 ), 350 350 ); 351 351 } ··· 356 356 $map = array( 357 357 'id' => $document->getID(), 358 358 'depth' => $document->getDepth(), 359 - 'updated' => $document->getContentID(), 359 + 'updated' => $document->getEditedEpoch(), 360 360 ); 361 361 362 362 foreach ($keys as $key) {
+2 -2
src/applications/phriction/storage/PhrictionContent.php
··· 7 7 PhabricatorDestructibleInterface, 8 8 PhabricatorConduitResultInterface { 9 9 10 - protected $documentID; 10 + protected $documentPHID; 11 11 protected $version; 12 12 protected $authorPHID; 13 13 ··· 35 35 ), 36 36 self::CONFIG_KEY_SCHEMA => array( 37 37 'documentID' => array( 38 - 'columns' => array('documentID', 'version'), 38 + 'columns' => array('documentPHID', 'version'), 39 39 'unique' => true, 40 40 ), 41 41 'authorPHID' => array(
+11 -14
src/applications/phriction/storage/PhrictionDocument.php
··· 17 17 18 18 protected $slug; 19 19 protected $depth; 20 - protected $contentID; 20 + protected $contentPHID; 21 21 protected $status; 22 22 protected $mailKey; 23 23 protected $viewPolicy; 24 24 protected $editPolicy; 25 25 protected $spacePHID; 26 + protected $editedEpoch; 26 27 27 28 private $contentObject = self::ATTACHABLE; 28 29 private $ancestors = array(); ··· 34 35 self::CONFIG_COLUMN_SCHEMA => array( 35 36 'slug' => 'sort128', 36 37 'depth' => 'uint32', 37 - 'contentID' => 'id?', 38 38 'status' => 'text32', 39 39 'mailKey' => 'bytes20', 40 + 'editedEpoch' => 'epoch', 40 41 ), 41 42 self::CONFIG_KEY_SCHEMA => array( 42 - 'key_phid' => null, 43 - 'phid' => array( 44 - 'columns' => array('phid'), 45 - 'unique' => true, 46 - ), 47 43 'slug' => array( 48 44 'columns' => array('slug'), 49 45 'unique' => true, ··· 56 52 ) + parent::getConfiguration(); 57 53 } 58 54 59 - public function generatePHID() { 60 - return PhabricatorPHID::generateNewPHID( 61 - PhrictionDocumentPHIDType::TYPECONST); 55 + public function getPHIDType() { 56 + return PhrictionDocumentPHIDType::TYPECONST; 62 57 } 63 58 64 59 public static function initializeNewDocument(PhabricatorUser $actor, $slug) { 65 - $document = new PhrictionDocument(); 66 - $document->setSlug($slug); 60 + $document = id(new self()) 61 + ->setSlug($slug); 67 62 68 - $content = new PhrictionContent(); 69 - $content->setSlug($slug); 63 + $content = id(new PhrictionContent()) 64 + ->setSlug($slug); 70 65 71 66 $default_title = PhabricatorSlug::getDefaultTitle($slug); 72 67 $content->setTitle($default_title); ··· 94 89 ->setEditPolicy(PhabricatorPolicies::POLICY_USER) 95 90 ->setSpacePHID($actor->getDefaultSpacePHID()); 96 91 } 92 + 93 + $document->setEditedEpoch(PhabricatorTime::getNow()); 97 94 98 95 return $document; 99 96 }
+3 -4
src/applications/phriction/xaction/PhrictionDocumentContentTransaction.php
··· 1 1 <?php 2 2 3 3 final class PhrictionDocumentContentTransaction 4 - extends PhrictionDocumentTransactionType { 4 + extends PhrictionDocumentVersionTransaction { 5 5 6 6 const TRANSACTIONTYPE = 'content'; 7 7 ··· 18 18 19 19 public function applyInternalEffects($object, $value) { 20 20 $object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS); 21 - } 22 21 23 - public function applyExternalEffects($object, $value) { 24 - $this->getEditor()->getNewContent()->setContent($value); 22 + $content = $this->getNewDocumentContent($object); 23 + $content->setContent($value); 25 24 } 26 25 27 26 public function shouldHide() {
+5 -6
src/applications/phriction/xaction/PhrictionDocumentDeleteTransaction.php
··· 1 1 <?php 2 2 3 3 final class PhrictionDocumentDeleteTransaction 4 - extends PhrictionDocumentTransactionType { 4 + extends PhrictionDocumentVersionTransaction { 5 5 6 6 const TRANSACTIONTYPE = 'delete'; 7 7 ··· 11 11 12 12 public function applyInternalEffects($object, $value) { 13 13 $object->setStatus(PhrictionDocumentStatus::STATUS_DELETED); 14 - } 14 + 15 + $content = $this->getNewDocumentContent($object); 15 16 16 - public function applyExternalEffects($object, $value) { 17 - $this->getEditor()->getNewContent()->setContent(''); 18 - $this->getEditor()->getNewContent()->setChangeType( 19 - PhrictionChangeType::CHANGE_DELETE); 17 + $content->setContent(''); 18 + $content->setChangeType(PhrictionChangeType::CHANGE_DELETE); 20 19 } 21 20 22 21 public function getActionStrength() {
+6 -8
src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php
··· 1 1 <?php 2 2 3 3 final class PhrictionDocumentMoveAwayTransaction 4 - extends PhrictionDocumentTransactionType { 4 + extends PhrictionDocumentVersionTransaction { 5 5 6 6 const TRANSACTIONTYPE = 'move-away'; 7 7 ··· 22 22 23 23 public function applyInternalEffects($object, $value) { 24 24 $object->setStatus(PhrictionDocumentStatus::STATUS_MOVED); 25 - } 26 25 27 - public function applyExternalEffects($object, $value) { 28 - $dict = $value; 29 - $this->getEditor()->getNewContent()->setContent(''); 30 - $this->getEditor()->getNewContent()->setChangeType( 31 - PhrictionChangeType::CHANGE_MOVE_AWAY); 32 - $this->getEditor()->getNewContent()->setChangeRef($dict['id']); 26 + $content = $this->getNewDocumentContent($object); 27 + 28 + $content->setContent(''); 29 + $content->setChangeType(PhrictionChangeType::CHANGE_MOVE_AWAY); 30 + $content->setChangeRef($value['id']); 33 31 } 34 32 35 33 public function getActionName() {
+8 -9
src/applications/phriction/xaction/PhrictionDocumentMoveToTransaction.php
··· 1 1 <?php 2 2 3 3 final class PhrictionDocumentMoveToTransaction 4 - extends PhrictionDocumentTransactionType { 4 + extends PhrictionDocumentVersionTransaction { 5 5 6 6 const TRANSACTIONTYPE = 'move-to'; 7 7 ··· 11 11 12 12 public function generateNewValue($object, $value) { 13 13 $document = $value; 14 + 14 15 $dict = array( 15 16 'id' => $document->getID(), 16 17 'phid' => $document->getPHID(), ··· 26 27 27 28 public function applyInternalEffects($object, $value) { 28 29 $object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS); 29 - } 30 + 31 + $content = $this->getNewDocumentContent($object); 30 32 31 - public function applyExternalEffects($object, $value) { 32 - $dict = $value; 33 - $this->getEditor()->getNewContent()->setContent($dict['content']); 34 - $this->getEditor()->getNewContent()->setTitle($dict['title']); 35 - $this->getEditor()->getNewContent()->setChangeType( 36 - PhrictionChangeType::CHANGE_MOVE_HERE); 37 - $this->getEditor()->getNewContent()->setChangeRef($dict['id']); 33 + $content->setContent($value['content']); 34 + $content->setTitle($value['title']); 35 + $content->setChangeType(PhrictionChangeType::CHANGE_MOVE_HERE); 36 + $content->setChangeRef($value['id']); 38 37 } 39 38 40 39 public function getActionStrength() {
+4 -4
src/applications/phriction/xaction/PhrictionDocumentTitleTransaction.php
··· 1 1 <?php 2 2 3 3 final class PhrictionDocumentTitleTransaction 4 - extends PhrictionDocumentTransactionType { 4 + extends PhrictionDocumentVersionTransaction { 5 5 6 6 const TRANSACTIONTYPE = 'title'; 7 7 ··· 14 14 15 15 public function applyInternalEffects($object, $value) { 16 16 $object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS); 17 - } 18 17 19 - public function applyExternalEffects($object, $value) { 20 - $this->getEditor()->getNewContent()->setTitle($value); 18 + $content = $this->getNewDocumentContent($object); 19 + 20 + $content->setTitle($value); 21 21 } 22 22 23 23 public function getActionStrength() {
+10
src/applications/phriction/xaction/PhrictionDocumentVersionTransaction.php
··· 1 + <?php 2 + 3 + abstract class PhrictionDocumentVersionTransaction 4 + extends PhrictionDocumentTransactionType { 5 + 6 + protected function getNewDocumentContent($object) { 7 + return $this->getEditor()->getNewDocumentContent($object); 8 + } 9 + 10 + }