Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15414535
D10018.id24154.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D10018.id24154.diff
View Options
diff --git a/resources/sql/autopatches/20140722.audit.3.miginlines.php b/resources/sql/autopatches/20140722.audit.3.miginlines.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140722.audit.3.miginlines.php
@@ -0,0 +1,77 @@
+<?php
+
+$audit_table = new PhabricatorAuditTransaction();
+$conn_w = $audit_table->establishConnection('w');
+$conn_w->openTransaction();
+
+$src_table = 'audit_inlinecomment';
+$dst_table = 'audit_transaction_comment';
+
+echo "Migrating Audit inline comments to new format...\n";
+
+$content_source = PhabricatorContentSource::newForSource(
+ PhabricatorContentSource::SOURCE_LEGACY,
+ array())->serialize();
+
+$rows = new LiskRawMigrationIterator($conn_w, $src_table);
+foreach ($rows as $row) {
+ $id = $row['id'];
+
+ echo "Migrating inline #{$id}...\n";
+
+ if ($row['auditCommentID']) {
+ $xaction_phid = PhabricatorPHID::generateNewPHID(
+ PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
+ PhabricatorRepositoryCommitPHIDType::TYPECONST);
+ } else {
+ $xaction_phid = null;
+ }
+
+ $comment_phid = PhabricatorPHID::generateNewPHID(
+ PhabricatorPHIDConstants::PHID_TYPE_XCMT,
+ PhabricatorRepositoryCommitPHIDType::TYPECONST);
+
+ queryfx(
+ $conn_w,
+ 'INSERT IGNORE INTO %T
+ (id, phid, transactionPHID, authorPHID, viewPolicy, editPolicy,
+ commentVersion, content, contentSource, isDeleted,
+ dateCreated, dateModified, commitPHID, pathID,
+ isNewFile, lineNumber, lineLength, hasReplies, legacyCommentID)
+ VALUES (%d, %s, %ns, %s, %s, %s,
+ %d, %s, %s, %d,
+ %d, %d, %s, %nd,
+ %d, %d, %d, %d, %nd)',
+ $dst_table,
+
+ // id, phid, transactionPHID, authorPHID, viewPolicy, editPolicy
+ $row['id'],
+ $comment_phid,
+ $xaction_phid,
+ $row['authorPHID'],
+ 'public',
+ $row['authorPHID'],
+
+ // commentVersion, content, contentSource, isDeleted
+ 1,
+ $row['content'],
+ $content_source,
+ 0,
+
+ // dateCreated, dateModified, commitPHID, pathID
+ $row['dateCreated'],
+ $row['dateModified'],
+ $row['commitPHID'],
+ $row['pathID'],
+
+ // isNewFile, lineNumber, lineLength, hasReplies, legacyCommentID
+ $row['isNewFile'],
+ $row['lineNumber'],
+ $row['lineLength'],
+ 0,
+ $row['auditCommentID']);
+
+}
+
+$conn_w->saveTransaction();
+echo "Done.\n";
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
@@ -3932,10 +3932,7 @@
'PhabricatorAuditCommentEditor' => 'PhabricatorEditor',
'PhabricatorAuditController' => 'PhabricatorController',
'PhabricatorAuditDAO' => 'PhabricatorLiskDAO',
- 'PhabricatorAuditInlineComment' => array(
- 'PhabricatorAuditDAO',
- 'PhabricatorInlineCommentInterface',
- ),
+ 'PhabricatorAuditInlineComment' => 'PhabricatorInlineCommentInterface',
'PhabricatorAuditListController' => 'PhabricatorAuditController',
'PhabricatorAuditListView' => 'AphrontView',
'PhabricatorAuditMailReceiver' => 'PhabricatorObjectMailReceiver',
diff --git a/src/applications/audit/storage/PhabricatorAuditInlineComment.php b/src/applications/audit/storage/PhabricatorAuditInlineComment.php
--- a/src/applications/audit/storage/PhabricatorAuditInlineComment.php
+++ b/src/applications/audit/storage/PhabricatorAuditInlineComment.php
@@ -1,39 +1,54 @@
<?php
final class PhabricatorAuditInlineComment
- extends PhabricatorAuditDAO
implements PhabricatorInlineCommentInterface {
- protected $commitPHID;
- protected $pathID;
- protected $auditCommentID;
+ private $proxy;
+ private $syntheticAuthor;
- protected $authorPHID;
- protected $isNewFile;
- protected $lineNumber;
- protected $lineLength;
- protected $content;
- protected $cache;
+ public function __construct() {
+ $this->proxy = new PhabricatorAuditTransactionComment();
+ }
- private $syntheticAuthor;
+ public function __clone() {
+ $this->proxy = clone $this->proxy;
+ }
+
+ public function getTransactionCommentForSave() {
+ $content_source = PhabricatorContentSource::newForSource(
+ PhabricatorContentSource::SOURCE_LEGACY,
+ array());
+
+ $this->proxy
+ ->setViewPolicy('public')
+ ->setEditPolicy($this->getAuthorPHID())
+ ->setContentSource($content_source)
+ ->setCommentVersion(1);
+
+ return $this->proxy;
+ }
public static function loadDraftComments(
PhabricatorUser $viewer,
$commit_phid) {
- return id(new PhabricatorAuditInlineComment())->loadAllWhere(
- 'authorPHID = %s AND commitPHID = %s AND auditCommentID IS NULL',
+ $inlines = id(new PhabricatorAuditTransactionComment())->loadAllWhere(
+ 'authorPHID = %s AND commitPHID = %s AND transactionPHID IS NULL',
$viewer->getPHID(),
$commit_phid);
+
+ return self::buildProxies($inlines);
}
public static function loadPublishedComments(
PhabricatorUser $viewer,
$commit_phid) {
- return id(new PhabricatorAuditInlineComment())->loadAllWhere(
- 'commitPHID = %s AND auditCommentID IS NOT NULL',
+ $inlines = id(new PhabricatorAuditTransactionComment())->loadAllWhere(
+ 'commitPHID = %s AND transactionPHID IS NOT NULL',
$commit_phid);
+
+ return self::buildProxies($inlines);
}
public static function loadDraftAndPublishedComments(
@@ -42,18 +57,29 @@
$path_id = null) {
if ($path_id === null) {
- return id(new PhabricatorAuditInlineComment())->loadAllWhere(
- 'commitPHID = %s AND (auditCommentID IS NOT NULL OR authorPHID = %s)',
+ $inlines = id(new PhabricatorAuditTransactionComment())->loadAllWhere(
+ 'commitPHID = %s AND (transactionPHID IS NOT NULL OR authorPHID = %s)',
$commit_phid,
$viewer->getPHID());
} else {
- return id(new PhabricatorAuditInlineComment())->loadAllWhere(
+ $inlines = id(new PhabricatorAuditTransactionComment())->loadAllWhere(
'commitPHID = %s AND pathID = %d AND
- (authorPHID = %s OR auditCommentID IS NOT NULL)',
+ (authorPHID = %s OR transactionPHID IS NOT NULL)',
$commit_phid,
$path_id,
$viewer->getPHID());
}
+
+ return self::buildProxies($inlines);
+ }
+
+ private static function buildProxies(array $inlines) {
+ $results = array();
+ foreach ($inlines as $key => $inline) {
+ $results[$key] = PhabricatorAuditInlineComment::newFromModernComment(
+ $inline);
+ }
+ return $results;
}
public function setSyntheticAuthor($synthetic_author) {
@@ -65,6 +91,43 @@
return $this->syntheticAuthor;
}
+ public function openTransaction() {
+ $this->proxy->openTransaction();
+ }
+
+ public function saveTransaction() {
+ $this->proxy->saveTransaction();
+ }
+
+ public function save() {
+ $this->getTransactionCommentForSave()->save();
+
+ return $this;
+ }
+
+ public function delete() {
+ $this->proxy->delete();
+
+ return $this;
+ }
+
+ public function getID() {
+ return $this->proxy->getID();
+ }
+
+ public function getPHID() {
+ return $this->proxy->getPHID();
+ }
+
+ public static function newFromModernComment(
+ PhabricatorAuditTransactionComment $comment) {
+
+ $obj = new PhabricatorAuditInlineComment();
+ $obj->proxy = $comment;
+
+ return $obj;
+ }
+
public function isCompatible(PhabricatorInlineCommentInterface $comment) {
return
($this->getAuthorPHID() === $comment->getAuthorPHID()) &&
@@ -73,76 +136,105 @@
}
public function setContent($content) {
- $this->setCache(null);
- $this->writeField('content', $content);
+ $this->proxy->setContent($content);
return $this;
}
public function getContent() {
- return $this->readField('content');
+ return $this->proxy->getContent();
}
public function isDraft() {
- return !$this->getAuditCommentID();
+ return !$this->proxy->getTransactionPHID();
}
- public function setChangesetID($id) {
- return $this->setPathID($id);
+ public function setPathID($id) {
+ $this->proxy->setPathID($id);
+ return $this;
}
- public function getChangesetID() {
- return $this->getPathID();
+ public function getPathID() {
+ return $this->proxy->getPathID();
}
- // NOTE: We need to provide implementations so we conform to the shared
- // interface; these are all trivial and just explicit versions of the Lisk
- // defaults.
-
public function setIsNewFile($is_new) {
- $this->writeField('isNewFile', $is_new);
+ $this->proxy->setIsNewFile($is_new);
return $this;
}
public function getIsNewFile() {
- return $this->readField('isNewFile');
+ return $this->proxy->getIsNewFile();
}
public function setLineNumber($number) {
- $this->writeField('lineNumber', $number);
+ $this->proxy->setLineNumber($number);
return $this;
}
public function getLineNumber() {
- return $this->readField('lineNumber');
+ return $this->proxy->getLineNumber();
}
public function setLineLength($length) {
- $this->writeField('lineLength', $length);
+ $this->proxy->setLineLength($length);
return $this;
}
public function getLineLength() {
- return $this->readField('lineLength');
+ return $this->proxy->getLineLength();
}
public function setCache($cache) {
- $this->writeField('cache', $cache);
return $this;
}
public function getCache() {
- return $this->readField('cache');
+ return null;
}
public function setAuthorPHID($phid) {
- $this->writeField('authorPHID', $phid);
+ $this->proxy->setAuthorPHID($phid);
return $this;
}
public function getAuthorPHID() {
- return $this->readField('authorPHID');
+ return $this->proxy->getAuthorPHID();
+ }
+
+ public function setCommitPHID($commit_phid) {
+ $this->proxy->setCommitPHID($commit_phid);
+ return $this;
+ }
+
+ public function getCommitPHID() {
+ return $this->proxy->getCommitPHID();
}
+ // When setting a comment ID, we also generate a phantom transaction PHID for
+ // the future transaction.
+
+ public function setAuditCommentID($id) {
+ $this->proxy->setLegacyCommentID($id);
+ $this->proxy->setTransactionPHID(
+ PhabricatorPHID::generateNewPHID(
+ PhabricatorApplicationTransactionTransactionPHIDType::TYPECONST,
+ PhabricatorRepositoryCommitPHIDType::TYPECONST));
+ return $this;
+ }
+
+ public function getAuditCommentID() {
+ return $this->proxy->getLegacyCommentID();
+ }
+
+ public function setChangesetID($id) {
+ return $this->setPathID($id);
+ }
+
+ public function getChangesetID() {
+ return $this->getPathID();
+ }
+
+
/* -( PhabricatorMarkupInterface Implementation )-------------------------- */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 21, 1:04 AM (12 h, 42 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7706089
Default Alt Text
D10018.id24154.diff (10 KB)
Attached To
Mode
D10018: Migrate Audit inline comments to new storage
Attached
Detach File
Event Timeline
Log In to Comment