From 8b3eced0c74d4a9d9b2c624309f7907ff1355d2b Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 9 Apr 2014 08:37:23 -0700 Subject: [PATCH] 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 --- .../ManiphestTaskEditController.php | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/applications/maniphest/controller/ManiphestTaskEditController.php b/src/applications/maniphest/controller/ManiphestTaskEditController.php index 1177ad6358..8c21a332ec 100644 --- a/src/applications/maniphest/controller/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/ManiphestTaskEditController.php @@ -57,33 +57,17 @@ final class ManiphestTaskEditController extends ManiphestController { if ($can_edit_projects) { $projects = $request->getStr('projects'); if ($projects) { - $tokens = explode(';', $projects); + $tokens = $request->getStrList('projects'); - $slug_map = id(new PhabricatorProjectQuery()) - ->setViewer($user) - ->withPhrictionSlugs($tokens) - ->execute(); + foreach ($tokens as $key => $token) { + $tokens[$key] = '#'.$token; + } - $name_map = id(new PhabricatorProjectQuery()) + $default_projects = id(new PhabricatorObjectQuery()) ->setViewer($user) ->withNames($tokens) ->execute(); - - $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(); - } - } + $default_projects = mpull($default_projects, 'getPHID'); if ($default_projects) { $task->setProjectPHIDs($default_projects);