diff --git a/resources/sql/autopatches/20141222.maniphestprojtxn.php b/resources/sql/autopatches/20141222.maniphestprojtxn.php new file mode 100644 index 0000000000..985fb1421b --- /dev/null +++ b/resources/sql/autopatches/20141222.maniphestprojtxn.php @@ -0,0 +1,48 @@ +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 index c72851c8dc..074fc36010 100644 --- a/src/applications/maniphest/storage/ManiphestTransaction.php +++ b/src/applications/maniphest/storage/ManiphestTransaction.php @@ -18,12 +18,6 @@ final class ManiphestTransaction // 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 @@ final class ManiphestTransaction $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 @@ final class ManiphestTransaction 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 @@ final class ManiphestTransaction 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 @@ final class ManiphestTransaction $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 @@ final class ManiphestTransaction $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 @@ final class ManiphestTransaction 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.'); }