Move all revision status transactions to modern values and mechanics
Summary:
Ref T2543. This updates and migrates the status change transactions:
- All storage now records the modern modular transaction ("differential.revision.status"), not the obsolete non-modular transaction ("differential:status").
- All storage now records the modern constants ("accepted"), not the obsolete numeric values ("2").
Test Plan:
- Selected all the relevant rows before/after migration, data looked sane.
- Browsed around, reviewed timelines, no changes after migration.
- Changed revision states, saw appropriate new transactions in the database and timeline rendering.
- Grepped for `differential:status`.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T2543
Differential Revision: https://secure.phabricator.com/D18419
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$map = array(
|
||||||
|
'0' => 'needs-review',
|
||||||
|
'1' => 'needs-revision',
|
||||||
|
'2' => 'accepted',
|
||||||
|
'3' => 'published',
|
||||||
|
'4' => 'abandoned',
|
||||||
|
'5' => 'changes-planned',
|
||||||
|
);
|
||||||
|
|
||||||
|
$table = new DifferentialTransaction();
|
||||||
|
$conn = $table->establishConnection('w');
|
||||||
|
|
||||||
|
foreach (new LiskMigrationIterator($table) as $xaction) {
|
||||||
|
$type = $xaction->getTransactionType();
|
||||||
|
|
||||||
|
if (($type != 'differential:status') &&
|
||||||
|
($type != 'differential.revision.status')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$old = $xaction->getOldValue();
|
||||||
|
$new = $xaction->getNewValue();
|
||||||
|
|
||||||
|
$old = idx($map, $old, $old);
|
||||||
|
$new = idx($map, $new, $new);
|
||||||
|
|
||||||
|
queryfx(
|
||||||
|
$conn,
|
||||||
|
'UPDATE %T SET transactionType = %s, oldValue = %s, newValue = %s
|
||||||
|
WHERE id = %d',
|
||||||
|
$table->getTableName(),
|
||||||
|
'differential.revision.status',
|
||||||
|
json_encode($old),
|
||||||
|
json_encode($new),
|
||||||
|
$xaction->getID());
|
||||||
|
}
|
||||||
@@ -88,27 +88,6 @@ final class DifferentialRevisionStatus extends Phobject {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function newForLegacyStatus($legacy_status) {
|
|
||||||
$result = new self();
|
|
||||||
|
|
||||||
$map = self::getMap();
|
|
||||||
foreach ($map as $key => $spec) {
|
|
||||||
if (!isset($spec['legacy'])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($spec['legacy'] != $legacy_status) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result->key = $key;
|
|
||||||
$result->spec = $spec;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getAll() {
|
public static function getAll() {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
|
|||||||
@@ -535,27 +535,25 @@ final class DifferentialTransactionEditor
|
|||||||
return $xactions;
|
return $xactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
$old_legacy_status = $revision->getLegacyRevisionStatus();
|
$old_status = $revision->getModernRevisionStatus();
|
||||||
$revision->setModernRevisionStatus($new_status);
|
if ($new_status == $old_status) {
|
||||||
$new_legacy_status = $revision->getLegacyRevisionStatus();
|
|
||||||
if ($new_legacy_status == $old_legacy_status) {
|
|
||||||
return $xactions;
|
return $xactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
$xaction = id(new DifferentialTransaction())
|
$xaction = id(new DifferentialTransaction())
|
||||||
->setTransactionType(
|
->setTransactionType(
|
||||||
DifferentialRevisionStatusTransaction::TRANSACTIONTYPE)
|
DifferentialRevisionStatusTransaction::TRANSACTIONTYPE)
|
||||||
->setOldValue($old_legacy_status)
|
->setOldValue($old_status)
|
||||||
->setNewValue($new_legacy_status);
|
->setNewValue($new_status);
|
||||||
|
|
||||||
$xaction = $this->populateTransaction($revision, $xaction)
|
$xaction = $this->populateTransaction($revision, $xaction)
|
||||||
->save();
|
->save();
|
||||||
$xactions[] = $xaction;
|
$xactions[] = $xaction;
|
||||||
|
|
||||||
// Save the status adjustment we made earlier.
|
// Save the status adjustment we made earlier.
|
||||||
// TODO: This can be a little cleaner and more obvious once storage
|
$revision
|
||||||
// migrates.
|
->setModernRevisionStatus($new_status)
|
||||||
$revision->save();
|
->save();
|
||||||
|
|
||||||
return $xactions;
|
return $xactions;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ final class DifferentialTransaction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($xaction_type == 'differential:status') {
|
|
||||||
return new DifferentialRevisionStatusTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::newFallbackModularTransactionType();
|
return parent::newFallbackModularTransactionType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,13 +509,8 @@ final class DifferentialTransaction
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function isStatusTransaction($xaction) {
|
private function isStatusTransaction($xaction) {
|
||||||
$old_status = 'differential:status';
|
$status_type = DifferentialRevisionStatusTransaction::TRANSACTIONTYPE;
|
||||||
if ($xaction->getTransactionType() == $old_status) {
|
if ($xaction->getTransactionType() == $status_type) {
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_status = DifferentialRevisionStatusTransaction::TRANSACTIONTYPE;
|
|
||||||
if ($xaction->getTransactionType() == $new_status) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ final class DifferentialRevisionStatusTransaction
|
|||||||
const TRANSACTIONTYPE = 'differential.revision.status';
|
const TRANSACTIONTYPE = 'differential.revision.status';
|
||||||
|
|
||||||
public function generateOldValue($object) {
|
public function generateOldValue($object) {
|
||||||
return $object->getLegacyRevisionStatus();
|
return $object->getModernRevisionStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyInternalEffects($object, $value) {
|
public function applyInternalEffects($object, $value) {
|
||||||
$object->setLegacyRevisionStatus($value);
|
$object->setModernRevisionStatus($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle() {
|
public function getTitle() {
|
||||||
@@ -67,7 +67,7 @@ final class DifferentialRevisionStatusTransaction
|
|||||||
|
|
||||||
private function newStatusObject() {
|
private function newStatusObject() {
|
||||||
$new = $this->getNewValue();
|
$new = $this->getNewValue();
|
||||||
return DifferentialRevisionStatus::newForLegacyStatus($new);
|
return DifferentialRevisionStatus::newForStatus($new);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user