Page MenuHomePhabricator

D11032.diff
No OneTemporary

D11032.diff

diff --git a/resources/sql/autopatches/20141222.maniphestprojtxn.php b/resources/sql/autopatches/20141222.maniphestprojtxn.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20141222.maniphestprojtxn.php
@@ -0,0 +1,48 @@
+<?php
+
+$table = new ManiphestTransaction();
+$conn_w = $table->establishConnection('w');
+
+echo "Converting Maniphest project transactions to modern EDGE ".
+ "transactions...\n";
+$metadata = array(
+ 'edge:type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,);
+foreach (new LiskMigrationIterator($table) as $txn) {
+ // ManiphestTransaction::TYPE_PROJECTS
+ if ($txn->getTransactionType() == 'projects') {
+ $old_value = mig20141222_build_edge_data(
+ $txn->getOldValue(),
+ $txn->getObjectPHID());
+ $new_value = mig20141222_build_edge_data(
+ $txn->getNewvalue(),
+ $txn->getObjectPHID());
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET '.
+ 'transactionType = %s, oldValue = %s, newValue = %s, metaData = %s '.
+ 'WHERE id = %d',
+ $table->getTableName(),
+ PhabricatorTransactions::TYPE_EDGE,
+ json_encode($old_value),
+ json_encode($new_value),
+ json_encode($metadata),
+ $txn->getID());
+ }
+}
+
+echo "Done.\n";
+
+function mig20141222_build_edge_data(array $project_phids, $task_phid) {
+ $edge_data = array();
+ foreach ($project_phids as $project_phid) {
+ if (!is_scalar($project_phid)) {
+ continue;
+ }
+ $edge_data[$project_phid] = array(
+ 'src' => $task_phid,
+ 'type' => PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
+ 'dst' => $project_phid,
+ );
+ }
+ return $edge_data;
+}
diff --git a/src/applications/maniphest/storage/ManiphestTransaction.php b/src/applications/maniphest/storage/ManiphestTransaction.php
--- a/src/applications/maniphest/storage/ManiphestTransaction.php
+++ b/src/applications/maniphest/storage/ManiphestTransaction.php
@@ -18,12 +18,6 @@
// NOTE: this type is deprecated. Keep it around for legacy installs
// so any transactions render correctly.
const TYPE_ATTACH = 'attach';
- /**
- * TYPE_PROJECTS is legacy and depracted in favor of
- * PhabricatorTransactions::TYPE_EDGE; keep it around for legacy
- * transaction-rendering.
- */
- const TYPE_PROJECTS = 'projects';
const MAILTAG_STATUS = 'maniphest-status';
const MAILTAG_OWNER = 'maniphest-owner';
@@ -87,14 +81,6 @@
$phids[] = $old;
}
break;
- case self::TYPE_PROJECTS:
- $phids = array_mergev(
- array(
- $phids,
- nonempty($old, array()),
- nonempty($new, array()),
- ));
- break;
case self::TYPE_PROJECT_COLUMN:
$phids[] = $new['projectPHID'];
$phids[] = head($new['columnPHIDs']);
@@ -267,9 +253,6 @@
return pht('Reassigned');
}
- case self::TYPE_PROJECTS:
- return pht('Changed Projects');
-
case self::TYPE_PROJECT_COLUMN:
return pht('Changed Project Column');
@@ -340,9 +323,6 @@
case self::TYPE_DESCRIPTION:
return 'fa-pencil';
- case self::TYPE_PROJECTS:
- return 'fa-briefcase';
-
case self::TYPE_PROJECT_COLUMN:
return 'fa-columns';
@@ -483,36 +463,6 @@
$this->renderHandleLink($new));
}
- case self::TYPE_PROJECTS:
- $added = array_diff($new, $old);
- $removed = array_diff($old, $new);
- if ($added && !$removed) {
- return pht(
- '%s added %d project(s): %s',
- $this->renderHandleLink($author_phid),
- count($added),
- $this->renderHandleList($added));
- } else if ($removed && !$added) {
- return pht(
- '%s removed %d project(s): %s',
- $this->renderHandleLink($author_phid),
- count($removed),
- $this->renderHandleList($removed));
- } else if ($removed && $added) {
- return pht(
- '%s changed project(s), added %d: %s; removed %d: %s',
- $this->renderHandleLink($author_phid),
- count($added),
- $this->renderHandleList($added),
- count($removed),
- $this->renderHandleList($removed));
- } else {
- // This is hit when rendering previews.
- return pht(
- '%s changed projects...',
- $this->renderHandleLink($author_phid));
- }
-
case self::TYPE_PRIORITY:
$old_name = ManiphestTaskPriority::getTaskPriorityName($old);
$new_name = ManiphestTaskPriority::getTaskPriorityName($new);
@@ -730,34 +680,6 @@
$this->renderHandleLink($new));
}
- case self::TYPE_PROJECTS:
- $added = array_diff($new, $old);
- $removed = array_diff($old, $new);
- if ($added && !$removed) {
- return pht(
- '%s added %d project(s) to %s: %s',
- $this->renderHandleLink($author_phid),
- count($added),
- $this->renderHandleLink($object_phid),
- $this->renderHandleList($added));
- } else if ($removed && !$added) {
- return pht(
- '%s removed %d project(s) from %s: %s',
- $this->renderHandleLink($author_phid),
- count($removed),
- $this->renderHandleLink($object_phid),
- $this->renderHandleList($removed));
- } else if ($removed && $added) {
- return pht(
- '%s changed project(s) of %s, added %d: %s; removed %d: %s',
- $this->renderHandleLink($author_phid),
- $this->renderHandleLink($object_phid),
- count($added),
- $this->renderHandleList($added),
- count($removed),
- $this->renderHandleList($removed));
- }
-
case self::TYPE_PRIORITY:
$old_name = ManiphestTaskPriority::getTaskPriorityName($old);
$new_name = ManiphestTaskPriority::getTaskPriorityName($new);
@@ -917,8 +839,6 @@
return pht('The task already has the selected status.');
case self::TYPE_OWNER:
return pht('The task already has the selected owner.');
- case self::TYPE_PROJECTS:
- return pht('The task is already associated with those projects.');
case self::TYPE_PRIORITY:
return pht('The task already has the selected priority.');
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 8, 3:51 PM (2 w, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7383087
Default Alt Text
D11032.diff (6 KB)

Event Timeline