1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

Make Maniphest project prefill more modern and standard

Summary: Fixes T4777. We technically support `?projects=...` already, but parse it in an unusual way and apply old, awkward, excessively strict lookups to it.

Test Plan: Used reasonable, standard, human-readable strings to prefill `?projects=` and got the results I expected.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T4777

Differential Revision: https://secure.phabricator.com/D8733
This commit is contained in:
epriestley 2014-04-09 08:37:23 -07:00
parent dffbbaf0a6
commit 8b3eced0c7

View file

@ -57,33 +57,17 @@ final class ManiphestTaskEditController extends ManiphestController {
if ($can_edit_projects) { if ($can_edit_projects) {
$projects = $request->getStr('projects'); $projects = $request->getStr('projects');
if ($projects) { if ($projects) {
$tokens = explode(';', $projects); $tokens = $request->getStrList('projects');
$slug_map = id(new PhabricatorProjectQuery()) foreach ($tokens as $key => $token) {
->setViewer($user) $tokens[$key] = '#'.$token;
->withPhrictionSlugs($tokens) }
->execute();
$name_map = id(new PhabricatorProjectQuery()) $default_projects = id(new PhabricatorObjectQuery())
->setViewer($user) ->setViewer($user)
->withNames($tokens) ->withNames($tokens)
->execute(); ->execute();
$default_projects = mpull($default_projects, 'getPHID');
$phid_map = id(new PhabricatorProjectQuery())
->setViewer($user)
->withPHIDs($tokens)
->execute();
$all_map = mpull($slug_map, null, 'getPhrictionSlug') +
mpull($name_map, null, 'getName') +
mpull($phid_map, null, 'getPHID');
$default_projects = array();
foreach ($tokens as $token) {
if (isset($all_map[$token])) {
$default_projects[] = $all_map[$token]->getPHID();
}
}
if ($default_projects) { if ($default_projects) {
$task->setProjectPHIDs($default_projects); $task->setProjectPHIDs($default_projects);