1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 08:12:40 +01:00
phorge-phorge/src/applications/differential/storage/DifferentialInlineComment.php

203 lines
4.6 KiB
PHP
Raw Normal View History

<?php
final class DifferentialInlineComment
implements PhabricatorInlineCommentInterface {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
private $proxy;
private $syntheticAuthor;
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
public function __construct() {
$this->proxy = new DifferentialTransactionComment();
}
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
public function __clone() {
$this->proxy = clone $this->proxy;
}
public function save() {
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_LEGACY,
array());
$this->proxy
->setViewPolicy('public')
->setEditPolicy($this->getAuthorPHID())
->setContentSource($content_source)
->setCommentVersion(1)
->save();
return $this;
}
public function delete() {
$this->proxy->delete();
return $this;
}
public function getID() {
return $this->proxy->getID();
}
public static function newFromModernComment(
DifferentialTransactionComment $comment) {
$obj = new DifferentialInlineComment();
$obj->proxy = $comment;
return $obj;
}
public function setSyntheticAuthor($synthetic_author) {
$this->syntheticAuthor = $synthetic_author;
return $this;
}
public function getSyntheticAuthor() {
return $this->syntheticAuthor;
}
public function isCompatible(PhabricatorInlineCommentInterface $comment) {
return
($this->getAuthorPHID() === $comment->getAuthorPHID()) &&
($this->getSyntheticAuthor() === $comment->getSyntheticAuthor()) &&
($this->getContent() === $comment->getContent());
}
public function setContent($content) {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
$this->proxy->setContent($content);
return $this;
}
public function getContent() {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
return $this->proxy->getContent();
}
public function isDraft() {
return !$this->getCommentID();
}
public function setChangesetID($id) {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
$this->proxy->setChangesetID($id);
return $this;
}
public function getChangesetID() {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
return $this->proxy->getChangesetID();
}
public function setIsNewFile($is_new) {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
$this->proxy->setIsNewFile($is_new);
return $this;
}
public function getIsNewFile() {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
return $this->proxy->getIsNewFile();
}
public function setLineNumber($number) {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
$this->proxy->setLineNumber($number);
return $this;
}
public function getLineNumber() {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
return $this->proxy->getLineNumber();
}
public function setLineLength($length) {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
$this->proxy->setLineLength($length);
return $this;
}
public function getLineLength() {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
return $this->proxy->getLineLength();
}
public function setCache($cache) {
return $this;
}
public function getCache() {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
return null;
}
public function setAuthorPHID($phid) {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
$this->proxy->setAuthorPHID($phid);
return $this;
}
public function getAuthorPHID() {
Migrate all Differential inline comments to ApplicationTransactions Summary: Ref T2222. This implements step (1) described there, which is moving over all the inline comments. The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later. Two risks here: - I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after. - This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this. I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive. Test Plan: - Before migrating, then after migrating: - Made a bunch of inlines (drafts, submitted). - Edited and deleted inlines. - Verified inlines showed up in preview. - Verified that inlines aren't indexed when they're drafts (`bin/search index D935`). - Verified that inlines ARE indexed when they're not drafts. - Verified that drafts inlines make revisions appear as "with draft" in the revision list. - Made left, right, and draft inlines. - Migrated (`bin/storage upgrade`). - Verified that my inlines from before the migration still showed up. - (Repeated all the stuff above.) - Manually inspected the inline comment table. Reviewers: btrahan Reviewed By: btrahan CC: FacebookPOC, aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
return $this->proxy->getAuthorPHID();
}
public function setRevision(DifferentialRevision $revision) {
$this->proxy->setRevisionPHID($revision->getPHID());
return $this;
}
// Although these are purely transitional, they're also *extra* dumb.
public function setRevisionID($revision_id) {
$revision = id(new DifferentialRevision())->load($revision_id);
return $this->setRevision($revision);
}
public function getRevisionID() {
$phid = $this->proxy->getRevisionPHID();
if (!$phid) {
return null;
}
$revision = id(new DifferentialRevision())->loadOneWhere(
'phid = %s',
$phid);
if (!$revision) {
return null;
}
return $revision->getID();
}
// When setting a comment ID, we also generate a phantom transaction PHID for
// the future transaction.
public function setCommentID($id) {
$this->proxy->setLegacyCommentID($id);
$this->proxy->setTransactionPHID(
PhabricatorPHID::generateNewPHID(
PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST,
DifferentialPHIDTypeRevision::TYPECONST));
return $this;
}
public function getCommentID() {
return $this->proxy->getLegacyCommentID();
}
/* -( PhabricatorMarkupInterface Implementation )-------------------------- */
public function getMarkupFieldKey($field) {
// We can't use ID because synthetic comments don't have it.
return 'DI:'.PhabricatorHash::digest($this->getContent());
}
public function newMarkupEngine($field) {
return PhabricatorMarkupEngine::newDifferentialMarkupEngine();
}
public function getMarkupText($field) {
return $this->getContent();
}
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
return $output;
}
public function shouldUseMarkupCache($field) {
// Only cache submitted comments.
return ($this->getID() && $this->getCommentID());
}
}