Index: resources/sql/patches/20131118.ownerorder.php =================================================================== --- /dev/null +++ resources/sql/patches/20131118.ownerorder.php @@ -0,0 +1,38 @@ +establishConnection('w'); + +foreach (new LiskMigrationIterator($table) as $task) { + $id = $task->getID(); + + echo "Checking task T{$id}...\n"; + $owner_phid = $task->getOwnerPHID(); + + if (!$owner_phid && !$task->getOwnerOrdering()) { + // No owner and no ordering; we're all set. + continue; + } + + $owner_handle = id(new PhabricatorHandleQuery()) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->withPHIDs(array($owner_phid)) + ->executeOne(); + + if ($owner_handle) { + $value = $owner_handle->getName(); + } else { + $value = null; + } + + if ($value !== $task->getOwnerOrdering()) { + queryfx( + $conn_w, + 'UPDATE %T SET ownerOrdering = %ns WHERE id = %d', + $table->getTableName(), + $value, + $task->getID()); + } +} + +echo "Done.\n"; Index: src/applications/maniphest/editor/ManiphestTransactionEditor.php =================================================================== --- src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -117,7 +117,26 @@ case ManiphestTransaction::TYPE_DESCRIPTION: return $object->setDescription($xaction->getNewValue()); case ManiphestTransaction::TYPE_OWNER: - return $object->setOwnerPHID($xaction->getNewValue()); + $phid = $xaction->getNewValue(); + + // Update the "ownerOrdering" column to contain the full name of the + // owner, if the task is assigned. + + $handle = null; + if ($phid) { + $handle = id(new PhabricatorHandleQuery()) + ->setViewer($this->getActor()) + ->withPHIDs(array($phid)) + ->executeOne(); + } + + if ($handle) { + $object->setOwnerOrdering($handle->getName()); + } else { + $object->setOwnerOrdering(null); + } + + return $object->setOwnerPHID($phid); case ManiphestTransaction::TYPE_CCS: return $object->setCCPHIDs($xaction->getNewValue()); case ManiphestTransaction::TYPE_PROJECTS: Index: src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php =================================================================== --- src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -1756,6 +1756,10 @@ 'type' => 'php', 'name' => $this->getPatchPath('20131112.userverified.2.mig.php'), ), + '20131118.ownerorder.php' => array( + 'type' => 'php', + 'name' => $this->getPatchPath('20131118.ownerorder.php'), + ), ); } }