diff --git a/resources/sql/patches/20130921.xmigratemaniphest.php b/resources/sql/patches/20130921.xmigratemaniphest.php index 315390950..ccb7aaec3 100644 --- a/resources/sql/patches/20130921.xmigratemaniphest.php +++ b/resources/sql/patches/20130921.xmigratemaniphest.php @@ -1,148 +1,148 @@ <?php $task_table = new ManiphestTask(); $conn_w = $task_table->establishConnection('w'); $rows = new LiskRawMigrationIterator($conn_w, 'maniphest_transaction'); $conn_w->openTransaction(); // NOTE: These were the correct table names at the time of this patch. -$xaction_table_name = 'maniphest_transaction_pro'; +$xaction_table_name = 'maniphest_transactionpro'; $comment_table_name = 'maniphest_transaction_comment'; foreach ($rows as $row) { $row_id = $row['id']; $task_id = $row['taskID']; echo "Migrating row {$row_id} (T{$task_id})...\n"; $task_row = queryfx_one( $conn_w, 'SELECT phid FROM %T WHERE id = %d', $task_table->getTableName(), $task_id); if (!$task_row) { echo "Skipping, no such task.\n"; continue; } $task_phid = $task_row['phid']; $has_comment = strlen(trim($row['comments'])); $xaction_type = $row['transactionType']; $xaction_old = $row['oldValue']; $xaction_new = $row['newValue']; $xaction_source = $row['contentSource']; $xaction_meta = $row['metadata']; // Convert "aux" (auxiliary field) transactions to proper CustomField // transactions. The formats are very similar, except that the type constant // is different and the auxiliary key should be prefixed. if ($xaction_type == 'aux') { $xaction_meta = @json_decode($xaction_meta, true); $xaction_meta = nonempty($xaction_meta, array()); $xaction_type = PhabricatorTransactions::TYPE_CUSTOMFIELD; $aux_key = idx($xaction_meta, 'aux:key'); if (!preg_match('/^std:maniphest:/', $aux_key)) { $aux_key = 'std:maniphest:'.$aux_key; } $xaction_meta = array( 'customfield:key' => $aux_key, ); $xaction_meta = json_encode($xaction_meta); } // If this transaction did something other than just leaving a comment, // insert a new transaction for that action. If there was a comment (or // a comment in addition to an action) we'll insert that below. if ($row['transactionType'] != 'comment') { $xaction_phid = PhabricatorPHID::generateNewPHID( PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST, ManiphestPHIDTypeTask::TYPECONST); queryfx( $conn_w, 'INSERT INTO %T (phid, authorPHID, objectPHID, viewPolicy, editPolicy, commentPHID, commentVersion, transactionType, oldValue, newValue, contentSource, metadata, dateCreated, dateModified) VALUES (%s, %s, %s, %s, %s, %s, %d, %s, %ns, %ns, %s, %s, %d, %d)', $xaction_table_name, $xaction_phid, $row['authorPHID'], $task_phid, 'public', $row['authorPHID'], null, 0, $xaction_type, $xaction_old, $xaction_new, $xaction_source, $xaction_meta, $row['dateCreated'], $row['dateModified']); } // Now, if the old transaction has a comment, we insert an explicit new // transaction for it. if ($has_comment) { $comment_phid = PhabricatorPHID::generateNewPHID( PhabricatorPHIDConstants::PHID_TYPE_XCMT, ManiphestPHIDTypeTask::TYPECONST); $comment_version = 1; $comment_xaction_phid = PhabricatorPHID::generateNewPHID( PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST, ManiphestPHIDTypeTask::TYPECONST); // Insert the comment data. queryfx( $conn_w, 'INSERT INTO %T (phid, transactionPHID, authorPHID, viewPolicy, editPolicy, commentVersion, content, contentSource, isDeleted, dateCreated, dateModified) VALUES (%s, %s, %s, %s, %s, %d, %s, %s, %d, %d, %d)', $comment_table_name, $comment_phid, $comment_xaction_phid, $row['authorPHID'], 'public', $row['authorPHID'], $comment_version, $row['comments'], $xaction_source, 0, $row['dateCreated'], $row['dateModified']); queryfx( $conn_w, 'INSERT INTO %T (phid, authorPHID, objectPHID, viewPolicy, editPolicy, commentPHID, commentVersion, transactionType, oldValue, newValue, contentSource, metadata, dateCreated, dateModified) VALUES (%s, %s, %s, %s, %s, %s, %d, %s, %ns, %ns, %s, %s, %d, %d)', $xaction_table_name, $comment_xaction_phid, $row['authorPHID'], $task_phid, 'public', $row['authorPHID'], $comment_phid, $comment_version, PhabricatorTransactions::TYPE_COMMENT, $xaction_old, $xaction_new, $xaction_source, $xaction_meta, $row['dateCreated'], $row['dateModified']); } } $conn_w->saveTransaction(); echo "Done.\n"; diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php index 312fe5cc5..5fa93f7cd 100644 --- a/src/applications/maniphest/storage/ManiphestTask.php +++ b/src/applications/maniphest/storage/ManiphestTask.php @@ -1,241 +1,241 @@ <?php /** * @group maniphest */ final class ManiphestTask extends ManiphestDAO implements PhabricatorMarkupInterface, PhabricatorPolicyInterface, PhabricatorTokenReceiverInterface, PhrequentTrackableInterface, PhabricatorCustomFieldInterface { const MARKUP_FIELD_DESCRIPTION = 'markup:desc'; protected $phid; protected $authorPHID; protected $ownerPHID; protected $ccPHIDs = array(); - protected $status; + protected $status = ManiphestTaskStatus::STATUS_OPEN; protected $priority; - protected $subpriority; + protected $subpriority = 0; protected $title; protected $originalTitle; protected $description; protected $originalEmailSource; protected $mailKey; protected $attached = array(); protected $projectPHIDs = array(); private $projectsNeedUpdate; private $subscribersNeedUpdate; protected $ownerOrdering; private $groupByProjectPHID = self::ATTACHABLE; private $customFields = self::ATTACHABLE; public function getConfiguration() { return array( self::CONFIG_AUX_PHID => true, self::CONFIG_SERIALIZATION => array( 'ccPHIDs' => self::SERIALIZATION_JSON, 'attached' => self::SERIALIZATION_JSON, 'projectPHIDs' => self::SERIALIZATION_JSON, ), ) + parent::getConfiguration(); } public function loadDependsOnTaskPHIDs() { return PhabricatorEdgeQuery::loadDestinationPHIDs( $this->getPHID(), PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK); } public function loadDependedOnByTaskPHIDs() { return PhabricatorEdgeQuery::loadDestinationPHIDs( $this->getPHID(), PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK); } public function getAttachedPHIDs($type) { return array_keys(idx($this->attached, $type, array())); } public function generatePHID() { return PhabricatorPHID::generateNewPHID(ManiphestPHIDTypeTask::TYPECONST); } public function getCCPHIDs() { return array_values(nonempty($this->ccPHIDs, array())); } public function setProjectPHIDs(array $phids) { $this->projectPHIDs = array_values($phids); $this->projectsNeedUpdate = true; return $this; } public function getProjectPHIDs() { return array_values(nonempty($this->projectPHIDs, array())); } public function setCCPHIDs(array $phids) { $this->ccPHIDs = array_values($phids); $this->subscribersNeedUpdate = true; return $this; } public function setOwnerPHID($phid) { $this->ownerPHID = nonempty($phid, null); $this->subscribersNeedUpdate = true; return $this; } public function setTitle($title) { $this->title = $title; if (!$this->getID()) { $this->originalTitle = $title; } return $this; } public function attachGroupByProjectPHID($phid) { $this->groupByProjectPHID = $phid; return $this; } public function getGroupByProjectPHID() { return $this->assertAttached($this->groupByProjectPHID); } public function save() { if (!$this->mailKey) { $this->mailKey = Filesystem::readRandomCharacters(20); } $result = parent::save(); if ($this->projectsNeedUpdate) { // If we've changed the project PHIDs for this task, update the link // table. ManiphestTaskProject::updateTaskProjects($this); $this->projectsNeedUpdate = false; } if ($this->subscribersNeedUpdate) { // If we've changed the subscriber PHIDs for this task, update the link // table. ManiphestTaskSubscriber::updateTaskSubscribers($this); $this->subscribersNeedUpdate = false; } return $result; } /* -( Markup Interface )--------------------------------------------------- */ /** * @task markup */ public function getMarkupFieldKey($field) { $hash = PhabricatorHash::digest($this->getMarkupText($field)); $id = $this->getID(); return "maniphest:T{$id}:{$field}:{$hash}"; } /** * @task markup */ public function getMarkupText($field) { return $this->getDescription(); } /** * @task markup */ public function newMarkupEngine($field) { return PhabricatorMarkupEngine::newManiphestMarkupEngine(); } /** * @task markup */ public function didMarkupText( $field, $output, PhutilMarkupEngine $engine) { return $output; } /** * @task markup */ public function shouldUseMarkupCache($field) { return (bool)$this->getID(); } /* -( Policy Interface )--------------------------------------------------- */ public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT, ); } public function getPolicy($capability) { return PhabricatorPolicies::POLICY_USER; } public function hasAutomaticCapability($capability, PhabricatorUser $user) { return false; } /* -( PhabricatorTokenReceiverInterface )---------------------------------- */ public function getUsersToNotifyOfTokenGiven() { // Sort of ambiguous who this was intended for; just let them both know. return array_filter( array_unique( array( $this->getAuthorPHID(), $this->getOwnerPHID(), ))); } /* -( PhabricatorCustomFieldInterface )------------------------------------ */ public function getCustomFieldSpecificationForRole($role) { return PhabricatorEnv::getEnvConfig('maniphest.fields'); } public function getCustomFieldBaseClass() { return 'ManiphestCustomField'; } public function getCustomFields() { return $this->assertAttached($this->customFields); } public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { $this->customFields = $fields; return $this; } }