Page MenuHomePhabricator

D19619.id46903.diff
No OneTemporary

D19619.id46903.diff

diff --git a/resources/sql/autopatches/20180828.phriction.01.contentphid.sql b/resources/sql/autopatches/20180828.phriction.01.contentphid.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180828.phriction.01.contentphid.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_phriction.phriction_document
+ ADD contentPHID VARBINARY(64) NOT NULL;
diff --git a/resources/sql/autopatches/20180828.phriction.02.documentphid.sql b/resources/sql/autopatches/20180828.phriction.02.documentphid.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180828.phriction.02.documentphid.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_phriction.phriction_content
+ ADD documentPHID VARBINARY(64) NOT NULL;
diff --git a/resources/sql/autopatches/20180828.phriction.03.editedepoch.sql b/resources/sql/autopatches/20180828.phriction.03.editedepoch.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180828.phriction.03.editedepoch.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_phriction.phriction_document
+ ADD editedEpoch INT UNSIGNED NOT NULL;
diff --git a/resources/sql/autopatches/20180828.phriction.04.migrate.php b/resources/sql/autopatches/20180828.phriction.04.migrate.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180828.phriction.04.migrate.php
@@ -0,0 +1,57 @@
+<?php
+
+// Update the PhrictionDocument and PhrictionContent tables to refer to one
+// another by PHID instead of by ID.
+
+$document_table = new PhrictionDocument();
+$content_table = new PhrictionContent();
+
+$conn = $document_table->establishConnection('w');
+
+$document_iterator = new LiskRawMigrationIterator(
+ $conn,
+ $document_table->getTableName());
+foreach ($document_iterator as $row) {
+ $content_id = $row['contentID'];
+
+ $content_row = queryfx_one(
+ $conn,
+ 'SELECT phid, dateCreated FROM %T WHERE id = %d',
+ $content_table->getTableName(),
+ $content_id);
+
+ if (!$content_row) {
+ continue;
+ }
+
+ queryfx(
+ $conn,
+ 'UPDATE %T SET contentPHID = %s, editedEpoch = %d WHERE id = %d',
+ $document_table->getTableName(),
+ $content_row['phid'],
+ $content_row['dateCreated'],
+ $row['id']);
+}
+
+$content_iterator = new LiskRawMigrationIterator(
+ $conn,
+ $content_table->getTableName());
+foreach ($content_iterator as $row) {
+ $document_id = $row['documentID'];
+
+ $document_row = queryfx_one(
+ $conn,
+ 'SELECT phid FROM %T WHERE id = %d',
+ $document_table->getTableName(),
+ $document_id);
+ if (!$document_row) {
+ continue;
+ }
+
+ queryfx(
+ $conn,
+ 'UPDATE %T SET documentPHID = %s WHERE id = %d',
+ $content_table->getTableName(),
+ $document_row['phid'],
+ $row['id']);
+}
diff --git a/resources/sql/autopatches/20180828.phriction.05.contentid.sql b/resources/sql/autopatches/20180828.phriction.05.contentid.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180828.phriction.05.contentid.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_phriction.phriction_document
+ DROP contentID;
diff --git a/resources/sql/autopatches/20180828.phriction.06.documentid.sql b/resources/sql/autopatches/20180828.phriction.06.documentid.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20180828.phriction.06.documentid.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_phriction.phriction_content
+ DROP documentID;
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -5036,6 +5036,7 @@
'PhrictionDocumentTitleHeraldField' => 'applications/phriction/herald/PhrictionDocumentTitleHeraldField.php',
'PhrictionDocumentTitleTransaction' => 'applications/phriction/xaction/PhrictionDocumentTitleTransaction.php',
'PhrictionDocumentTransactionType' => 'applications/phriction/xaction/PhrictionDocumentTransactionType.php',
+ 'PhrictionDocumentVersionTransaction' => 'applications/phriction/xaction/PhrictionDocumentVersionTransaction.php',
'PhrictionEditConduitAPIMethod' => 'applications/phriction/conduit/PhrictionEditConduitAPIMethod.php',
'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php',
'PhrictionHistoryConduitAPIMethod' => 'applications/phriction/conduit/PhrictionHistoryConduitAPIMethod.php',
@@ -11129,17 +11130,17 @@
),
'PhrictionDocumentAuthorHeraldField' => 'PhrictionDocumentHeraldField',
'PhrictionDocumentContentHeraldField' => 'PhrictionDocumentHeraldField',
- 'PhrictionDocumentContentTransaction' => 'PhrictionDocumentTransactionType',
+ 'PhrictionDocumentContentTransaction' => 'PhrictionDocumentVersionTransaction',
'PhrictionDocumentController' => 'PhrictionController',
'PhrictionDocumentDatasource' => 'PhabricatorTypeaheadDatasource',
- 'PhrictionDocumentDeleteTransaction' => 'PhrictionDocumentTransactionType',
+ 'PhrictionDocumentDeleteTransaction' => 'PhrictionDocumentVersionTransaction',
'PhrictionDocumentFerretEngine' => 'PhabricatorFerretEngine',
'PhrictionDocumentFulltextEngine' => 'PhabricatorFulltextEngine',
'PhrictionDocumentHeraldAdapter' => 'HeraldAdapter',
'PhrictionDocumentHeraldField' => 'HeraldField',
'PhrictionDocumentHeraldFieldGroup' => 'HeraldFieldGroup',
- 'PhrictionDocumentMoveAwayTransaction' => 'PhrictionDocumentTransactionType',
- 'PhrictionDocumentMoveToTransaction' => 'PhrictionDocumentTransactionType',
+ 'PhrictionDocumentMoveAwayTransaction' => 'PhrictionDocumentVersionTransaction',
+ 'PhrictionDocumentMoveToTransaction' => 'PhrictionDocumentVersionTransaction',
'PhrictionDocumentPHIDType' => 'PhabricatorPHIDType',
'PhrictionDocumentPathHeraldField' => 'PhrictionDocumentHeraldField',
'PhrictionDocumentPolicyCodex' => 'PhabricatorPolicyCodex',
@@ -11148,8 +11149,9 @@
'PhrictionDocumentSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhrictionDocumentStatus' => 'PhabricatorObjectStatus',
'PhrictionDocumentTitleHeraldField' => 'PhrictionDocumentHeraldField',
- 'PhrictionDocumentTitleTransaction' => 'PhrictionDocumentTransactionType',
+ 'PhrictionDocumentTitleTransaction' => 'PhrictionDocumentVersionTransaction',
'PhrictionDocumentTransactionType' => 'PhabricatorModularTransactionType',
+ 'PhrictionDocumentVersionTransaction' => 'PhrictionDocumentTransactionType',
'PhrictionEditConduitAPIMethod' => 'PhrictionConduitAPIMethod',
'PhrictionEditController' => 'PhrictionController',
'PhrictionHistoryConduitAPIMethod' => 'PhrictionConduitAPIMethod',
diff --git a/src/applications/phriction/controller/PhrictionDiffController.php b/src/applications/phriction/controller/PhrictionDiffController.php
--- a/src/applications/phriction/controller/PhrictionDiffController.php
+++ b/src/applications/phriction/controller/PhrictionDiffController.php
@@ -65,8 +65,8 @@
$slug = $document->getSlug();
- $revert_l = $this->renderRevertButton($content_l, $current);
- $revert_r = $this->renderRevertButton($content_r, $current);
+ $revert_l = $this->renderRevertButton($document, $content_l, $current);
+ $revert_r = $this->renderRevertButton($document, $content_r, $current);
$crumbs = $this->buildApplicationCrumbs();
$crumb_views = $this->renderBreadcrumbs($slug);
@@ -179,10 +179,11 @@
}
private function renderRevertButton(
+ PhrictionDocument $document,
PhrictionContent $content,
PhrictionContent $current) {
- $document_id = $content->getDocumentID();
+ $document_id = $document->getID();
$version = $content->getVersion();
$hidden_statuses = array(
diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php
--- a/src/applications/phriction/controller/PhrictionDocumentController.php
+++ b/src/applications/phriction/controller/PhrictionDocumentController.php
@@ -78,7 +78,7 @@
return new Aphront404Response();
}
- if ($content->getID() != $document->getContentID()) {
+ if ($content->getPHID() != $document->getContentPHID()) {
$version_note = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
->appendChild(
diff --git a/src/applications/phriction/controller/PhrictionHistoryController.php b/src/applications/phriction/controller/PhrictionHistoryController.php
--- a/src/applications/phriction/controller/PhrictionHistoryController.php
+++ b/src/applications/phriction/controller/PhrictionHistoryController.php
@@ -52,7 +52,7 @@
}
$vs_head = null;
- if ($content->getID() != $document->getContentID()) {
+ if ($content->getPHID() != $document->getContentPHID()) {
$vs_head = $diff_uri
->alter('l', $content->getVersion())
->alter('r', $current->getVersion());
diff --git a/src/applications/phriction/editor/PhrictionTransactionEditor.php b/src/applications/phriction/editor/PhrictionTransactionEditor.php
--- a/src/applications/phriction/editor/PhrictionTransactionEditor.php
+++ b/src/applications/phriction/editor/PhrictionTransactionEditor.php
@@ -93,29 +93,13 @@
return $types;
}
- protected function shouldApplyInitialEffects(
- PhabricatorLiskDAO $object,
- array $xactions) {
-
- foreach ($xactions as $xaction) {
- switch ($xaction->getTransactionType()) {
- case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE:
- case PhrictionDocumentContentTransaction::TRANSACTIONTYPE:
- case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE:
- case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE:
- case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE:
- return true;
- }
- }
- return parent::shouldApplyInitialEffects($object, $xactions);
- }
-
- protected function applyInitialEffects(
+ protected function expandTransactions(
PhabricatorLiskDAO $object,
array $xactions) {
$this->setOldContent($object->getContent());
- $this->setNewContent($this->buildNewContentTemplate($object));
+
+ return parent::expandTransactions($object, $xactions);
}
protected function expandTransaction(
@@ -148,7 +132,6 @@
break;
default:
break;
-
}
return $xactions;
@@ -158,29 +141,12 @@
PhabricatorLiskDAO $object,
array $xactions) {
- $save_content = false;
- foreach ($xactions as $xaction) {
- switch ($xaction->getTransactionType()) {
- case PhrictionDocumentTitleTransaction::TRANSACTIONTYPE:
- case PhrictionDocumentMoveToTransaction::TRANSACTIONTYPE:
- case PhrictionDocumentMoveAwayTransaction::TRANSACTIONTYPE:
- case PhrictionDocumentDeleteTransaction::TRANSACTIONTYPE:
- case PhrictionDocumentContentTransaction::TRANSACTIONTYPE:
- $save_content = true;
- break;
- default:
- break;
- }
- }
-
- if ($save_content) {
- $content = $this->getNewContent();
- $content->setDocumentID($object->getID());
- $content->save();
+ if ($this->hasNewDocumentContent()) {
+ $content = $this->getNewDocumentContent($object);
- $object->setContentID($content->getID());
- $object->save();
- $object->attachContent($content);
+ $content
+ ->setDocumentPHID($object->getPHID())
+ ->save();
}
if ($this->getIsNewObject() && !$this->getSkipAncestorCheck()) {
@@ -535,24 +501,47 @@
->setDocument($object);
}
- private function buildNewContentTemplate(
- PhrictionDocument $document) {
+ private function hasNewDocumentContent() {
+ return (bool)$this->newContent;
+ }
+
+ public function getNewDocumentContent(PhrictionDocument $document) {
+ if (!$this->hasNewDocumentContent()) {
+ $content = $this->newDocumentContent($document);
+
+ // Generate a PHID now so we can populate "contentPHID" before saving
+ // the document to the database: the column is not nullable so we need
+ // a value.
+ $content_phid = $content->generatePHID();
+
+ $content->setPHID($content_phid);
+
+ $document->setContentPHID($content_phid);
+ $document->attachContent($content);
+ $document->setEditedEpoch(PhabricatorTime::getNow());
+
+ $this->newContent = $content;
+ }
+
+ return $this->newContent;
+ }
- $new_content = id(new PhrictionContent())
+ private function newDocumentContent(PhrictionDocument $document) {
+ $content = id(new PhrictionContent())
->setSlug($document->getSlug())
- ->setAuthorPHID($this->getActor()->getPHID())
+ ->setAuthorPHID($this->getActingAsPHID())
->setChangeType(PhrictionChangeType::CHANGE_EDIT)
->setTitle($this->getOldContent()->getTitle())
->setContent($this->getOldContent()->getContent())
->setDescription('');
if (strlen($this->getDescription())) {
- $new_content->setDescription($this->getDescription());
+ $content->setDescription($this->getDescription());
}
- $new_content->setVersion($this->getOldContent()->getVersion() + 1);
+ $content->setVersion($this->getOldContent()->getVersion() + 1);
- return $new_content;
+ return $content;
}
protected function getCustomWorkerState() {
diff --git a/src/applications/phriction/query/PhrictionContentQuery.php b/src/applications/phriction/query/PhrictionContentQuery.php
--- a/src/applications/phriction/query/PhrictionContentQuery.php
+++ b/src/applications/phriction/query/PhrictionContentQuery.php
@@ -76,7 +76,7 @@
if ($this->shouldJoinDocumentTable()) {
$joins[] = qsprintf(
$conn,
- 'JOIN %T d ON d.id = c.documentID',
+ 'JOIN %T d ON d.phid = c.documentPHID',
id(new PhrictionDocument())->getTableName());
}
@@ -84,19 +84,19 @@
}
protected function willFilterPage(array $contents) {
- $document_ids = mpull($contents, 'getDocumentID');
+ $document_phids = mpull($contents, 'getDocumentPHID');
$documents = id(new PhrictionDocumentQuery())
->setViewer($this->getViewer())
->setParentQuery($this)
- ->withIDs($document_ids)
+ ->withPHIDs($document_phids)
->execute();
- $documents = mpull($documents, null, 'getID');
+ $documents = mpull($documents, null, 'getPHID');
foreach ($contents as $key => $content) {
- $document_id = $content->getDocumentID();
+ $document_phid = $content->getDocumentPHID();
- $document = idx($documents, $document_id);
+ $document = idx($documents, $document_phid);
if (!$document) {
unset($contents[$key]);
$this->didRejectResult($content);
diff --git a/src/applications/phriction/query/PhrictionDocumentQuery.php b/src/applications/phriction/query/PhrictionDocumentQuery.php
--- a/src/applications/phriction/query/PhrictionDocumentQuery.php
+++ b/src/applications/phriction/query/PhrictionDocumentQuery.php
@@ -151,17 +151,17 @@
$contents = id(new PhrictionContentQuery())
->setViewer($this->getViewer())
->setParentQuery($this)
- ->withIDs(mpull($documents, 'getContentID'))
+ ->withPHIDs(mpull($documents, 'getContentPHID'))
->execute();
- $contents = mpull($contents, null, 'getID');
+ $contents = mpull($contents, null, 'getPHID');
foreach ($documents as $key => $document) {
- $content_id = $document->getContentID();
- if (empty($contents[$content_id])) {
+ $content_phid = $document->getContentPHID();
+ if (empty($contents[$content_phid])) {
unset($documents[$key]);
continue;
}
- $document->attachContent($contents[$content_id]);
+ $document->attachContent($contents[$content_phid]);
}
}
@@ -175,7 +175,7 @@
$content_dao = new PhrictionContent();
$joins[] = qsprintf(
$conn,
- 'JOIN %T c ON d.contentID = c.id',
+ 'JOIN %T c ON d.contentPHID = c.phid',
$content_dao->getTableName());
}
@@ -321,7 +321,7 @@
public function getBuiltinOrders() {
return parent::getBuiltinOrders() + array(
self::ORDER_HIERARCHY => array(
- 'vector' => array('depth', 'title', 'updated'),
+ 'vector' => array('depth', 'title', 'updated', 'id'),
'name' => pht('Hierarchy'),
),
);
@@ -343,9 +343,9 @@
),
'updated' => array(
'table' => 'd',
- 'column' => 'contentID',
+ 'column' => 'editedEpoch',
'type' => 'int',
- 'unique' => true,
+ 'unique' => false,
),
);
}
@@ -356,7 +356,7 @@
$map = array(
'id' => $document->getID(),
'depth' => $document->getDepth(),
- 'updated' => $document->getContentID(),
+ 'updated' => $document->getEditedEpoch(),
);
foreach ($keys as $key) {
diff --git a/src/applications/phriction/storage/PhrictionContent.php b/src/applications/phriction/storage/PhrictionContent.php
--- a/src/applications/phriction/storage/PhrictionContent.php
+++ b/src/applications/phriction/storage/PhrictionContent.php
@@ -7,7 +7,7 @@
PhabricatorDestructibleInterface,
PhabricatorConduitResultInterface {
- protected $documentID;
+ protected $documentPHID;
protected $version;
protected $authorPHID;
@@ -35,7 +35,7 @@
),
self::CONFIG_KEY_SCHEMA => array(
'documentID' => array(
- 'columns' => array('documentID', 'version'),
+ 'columns' => array('documentPHID', 'version'),
'unique' => true,
),
'authorPHID' => array(
diff --git a/src/applications/phriction/storage/PhrictionDocument.php b/src/applications/phriction/storage/PhrictionDocument.php
--- a/src/applications/phriction/storage/PhrictionDocument.php
+++ b/src/applications/phriction/storage/PhrictionDocument.php
@@ -17,12 +17,13 @@
protected $slug;
protected $depth;
- protected $contentID;
+ protected $contentPHID;
protected $status;
protected $mailKey;
protected $viewPolicy;
protected $editPolicy;
protected $spacePHID;
+ protected $editedEpoch;
private $contentObject = self::ATTACHABLE;
private $ancestors = array();
@@ -34,16 +35,11 @@
self::CONFIG_COLUMN_SCHEMA => array(
'slug' => 'sort128',
'depth' => 'uint32',
- 'contentID' => 'id?',
'status' => 'text32',
'mailKey' => 'bytes20',
+ 'editedEpoch' => 'epoch',
),
self::CONFIG_KEY_SCHEMA => array(
- 'key_phid' => null,
- 'phid' => array(
- 'columns' => array('phid'),
- 'unique' => true,
- ),
'slug' => array(
'columns' => array('slug'),
'unique' => true,
@@ -56,17 +52,16 @@
) + parent::getConfiguration();
}
- public function generatePHID() {
- return PhabricatorPHID::generateNewPHID(
- PhrictionDocumentPHIDType::TYPECONST);
+ public function getPHIDType() {
+ return PhrictionDocumentPHIDType::TYPECONST;
}
public static function initializeNewDocument(PhabricatorUser $actor, $slug) {
- $document = new PhrictionDocument();
- $document->setSlug($slug);
+ $document = id(new self())
+ ->setSlug($slug);
- $content = new PhrictionContent();
- $content->setSlug($slug);
+ $content = id(new PhrictionContent())
+ ->setSlug($slug);
$default_title = PhabricatorSlug::getDefaultTitle($slug);
$content->setTitle($default_title);
@@ -95,6 +90,8 @@
->setSpacePHID($actor->getDefaultSpacePHID());
}
+ $document->setEditedEpoch(PhabricatorTime::getNow());
+
return $document;
}
diff --git a/src/applications/phriction/xaction/PhrictionDocumentContentTransaction.php b/src/applications/phriction/xaction/PhrictionDocumentContentTransaction.php
--- a/src/applications/phriction/xaction/PhrictionDocumentContentTransaction.php
+++ b/src/applications/phriction/xaction/PhrictionDocumentContentTransaction.php
@@ -1,7 +1,7 @@
<?php
final class PhrictionDocumentContentTransaction
- extends PhrictionDocumentTransactionType {
+ extends PhrictionDocumentVersionTransaction {
const TRANSACTIONTYPE = 'content';
@@ -18,10 +18,9 @@
public function applyInternalEffects($object, $value) {
$object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS);
- }
- public function applyExternalEffects($object, $value) {
- $this->getEditor()->getNewContent()->setContent($value);
+ $content = $this->getNewDocumentContent($object);
+ $content->setContent($value);
}
public function shouldHide() {
diff --git a/src/applications/phriction/xaction/PhrictionDocumentDeleteTransaction.php b/src/applications/phriction/xaction/PhrictionDocumentDeleteTransaction.php
--- a/src/applications/phriction/xaction/PhrictionDocumentDeleteTransaction.php
+++ b/src/applications/phriction/xaction/PhrictionDocumentDeleteTransaction.php
@@ -1,7 +1,7 @@
<?php
final class PhrictionDocumentDeleteTransaction
- extends PhrictionDocumentTransactionType {
+ extends PhrictionDocumentVersionTransaction {
const TRANSACTIONTYPE = 'delete';
@@ -11,12 +11,11 @@
public function applyInternalEffects($object, $value) {
$object->setStatus(PhrictionDocumentStatus::STATUS_DELETED);
- }
- public function applyExternalEffects($object, $value) {
- $this->getEditor()->getNewContent()->setContent('');
- $this->getEditor()->getNewContent()->setChangeType(
- PhrictionChangeType::CHANGE_DELETE);
+ $content = $this->getNewDocumentContent($object);
+
+ $content->setContent('');
+ $content->setChangeType(PhrictionChangeType::CHANGE_DELETE);
}
public function getActionStrength() {
diff --git a/src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php b/src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php
--- a/src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php
+++ b/src/applications/phriction/xaction/PhrictionDocumentMoveAwayTransaction.php
@@ -1,7 +1,7 @@
<?php
final class PhrictionDocumentMoveAwayTransaction
- extends PhrictionDocumentTransactionType {
+ extends PhrictionDocumentVersionTransaction {
const TRANSACTIONTYPE = 'move-away';
@@ -22,14 +22,12 @@
public function applyInternalEffects($object, $value) {
$object->setStatus(PhrictionDocumentStatus::STATUS_MOVED);
- }
- public function applyExternalEffects($object, $value) {
- $dict = $value;
- $this->getEditor()->getNewContent()->setContent('');
- $this->getEditor()->getNewContent()->setChangeType(
- PhrictionChangeType::CHANGE_MOVE_AWAY);
- $this->getEditor()->getNewContent()->setChangeRef($dict['id']);
+ $content = $this->getNewDocumentContent($object);
+
+ $content->setContent('');
+ $content->setChangeType(PhrictionChangeType::CHANGE_MOVE_AWAY);
+ $content->setChangeRef($value['id']);
}
public function getActionName() {
diff --git a/src/applications/phriction/xaction/PhrictionDocumentMoveToTransaction.php b/src/applications/phriction/xaction/PhrictionDocumentMoveToTransaction.php
--- a/src/applications/phriction/xaction/PhrictionDocumentMoveToTransaction.php
+++ b/src/applications/phriction/xaction/PhrictionDocumentMoveToTransaction.php
@@ -1,7 +1,7 @@
<?php
final class PhrictionDocumentMoveToTransaction
- extends PhrictionDocumentTransactionType {
+ extends PhrictionDocumentVersionTransaction {
const TRANSACTIONTYPE = 'move-to';
@@ -11,6 +11,7 @@
public function generateNewValue($object, $value) {
$document = $value;
+
$dict = array(
'id' => $document->getID(),
'phid' => $document->getPHID(),
@@ -26,15 +27,13 @@
public function applyInternalEffects($object, $value) {
$object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS);
- }
- public function applyExternalEffects($object, $value) {
- $dict = $value;
- $this->getEditor()->getNewContent()->setContent($dict['content']);
- $this->getEditor()->getNewContent()->setTitle($dict['title']);
- $this->getEditor()->getNewContent()->setChangeType(
- PhrictionChangeType::CHANGE_MOVE_HERE);
- $this->getEditor()->getNewContent()->setChangeRef($dict['id']);
+ $content = $this->getNewDocumentContent($object);
+
+ $content->setContent($value['content']);
+ $content->setTitle($value['title']);
+ $content->setChangeType(PhrictionChangeType::CHANGE_MOVE_HERE);
+ $content->setChangeRef($value['id']);
}
public function getActionStrength() {
diff --git a/src/applications/phriction/xaction/PhrictionDocumentTitleTransaction.php b/src/applications/phriction/xaction/PhrictionDocumentTitleTransaction.php
--- a/src/applications/phriction/xaction/PhrictionDocumentTitleTransaction.php
+++ b/src/applications/phriction/xaction/PhrictionDocumentTitleTransaction.php
@@ -1,7 +1,7 @@
<?php
final class PhrictionDocumentTitleTransaction
- extends PhrictionDocumentTransactionType {
+ extends PhrictionDocumentVersionTransaction {
const TRANSACTIONTYPE = 'title';
@@ -14,10 +14,10 @@
public function applyInternalEffects($object, $value) {
$object->setStatus(PhrictionDocumentStatus::STATUS_EXISTS);
- }
- public function applyExternalEffects($object, $value) {
- $this->getEditor()->getNewContent()->setTitle($value);
+ $content = $this->getNewDocumentContent($object);
+
+ $content->setTitle($value);
}
public function getActionStrength() {
diff --git a/src/applications/phriction/xaction/PhrictionDocumentVersionTransaction.php b/src/applications/phriction/xaction/PhrictionDocumentVersionTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phriction/xaction/PhrictionDocumentVersionTransaction.php
@@ -0,0 +1,10 @@
+<?php
+
+abstract class PhrictionDocumentVersionTransaction
+ extends PhrictionDocumentTransactionType {
+
+ protected function getNewDocumentContent($object) {
+ return $this->getEditor()->getNewDocumentContent($object);
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Mon, May 13, 5:38 AM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6265170
Default Alt Text
D19619.id46903.diff (25 KB)

Event Timeline