@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support "M" in phid.lookup and ircbot

Summary: Fixes T2651. This could be futher generalized but it's a bit out of the way.

Test Plan: See chatlog.

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T2651

Differential Revision: https://secure.phabricator.com/D5236

+67 -58
+1 -1
src/applications/phid/conduit/ConduitAPI_phid_lookup_Method.php
··· 28 28 $names = $request->getValue('names'); 29 29 $phids = array(); 30 30 foreach ($names as $name) { 31 - $phid = PhabricatorPHID::fromObjectName($name); 31 + $phid = PhabricatorPHID::fromObjectName($name, $request->getUser()); 32 32 if ($phid) { 33 33 $phids[$name] = $phid; 34 34 }
+9 -1
src/applications/phid/storage/PhabricatorPHID.php
··· 24 24 return "PHID-{$type_str}-{$uniq}"; 25 25 } 26 26 27 - public static function fromObjectName($name) { 27 + public static function fromObjectName($name, PhabricatorUser $viewer) { 28 28 $object = null; 29 29 $match = null; 30 30 if (preg_match('/^PHID-[A-Z]+-.{20}$/', $name)) { ··· 56 56 $object = id(new DifferentialRevision())->load($match[1]); 57 57 } else if (preg_match('/^t(\d+)$/i', $name, $match)) { 58 58 $object = id(new ManiphestTask())->load($match[1]); 59 + } else if (preg_match('/^m(\d+)$/i', $name, $match)) { 60 + $objects = id(new PholioMockQuery()) 61 + ->setViewer($viewer) 62 + ->withIDs(array($match[1])) 63 + ->execute(); 64 + $object = head($objects); 59 65 } 66 + 60 67 if ($object) { 61 68 return $object->getPHID(); 62 69 } 70 + 63 71 return null; 64 72 } 65 73 }
+1 -1
src/applications/search/controller/PhabricatorSearchController.php
··· 221 221 $results = $pager->sliceResults($results); 222 222 223 223 if (!$request->getInt('page')) { 224 - $jump = PhabricatorPHID::fromObjectName($query->getQuery()); 224 + $jump = PhabricatorPHID::fromObjectName($query->getQuery(), $user); 225 225 if ($jump) { 226 226 array_unshift($results, $jump); 227 227 }
+3 -1
src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
··· 93 93 private function loadPHIDsByNames(array $names) { 94 94 $phids = array(); 95 95 foreach ($names as $name) { 96 - $phid = PhabricatorPHID::fromObjectName($name); 96 + $phid = PhabricatorPHID::fromObjectName( 97 + $name, 98 + PhabricatorUser::getOmnipotentUser()); 97 99 if (!$phid) { 98 100 throw new PhutilArgumentUsageException( 99 101 "'{$name}' is not the name of a known object.");
+53 -54
src/infrastructure/daemon/bot/handler/PhabricatorBotObjectNameHandler.php
··· 20 20 $message = $original_message->getBody(); 21 21 $matches = null; 22 22 23 + $paste_ids = array(); 24 + $commit_names = array(); 25 + $vote_ids = array(); 26 + $file_ids = array(); 27 + $object_names = array(); 28 + $output = array(); 29 + 23 30 $pattern = 24 31 '@'. 25 - '(?<!/)(?:^|\b)'. // Negative lookbehind prevent matching "/D123". 26 - '(D|T|P|V|F)(\d+)'. 32 + '(?<!/)(?:^|\b)'. 33 + '(R2D2)'. 27 34 '(?:\b|$)'. 28 35 '@'; 29 36 30 - $revision_ids = array(); 31 - $task_ids = array(); 32 - $paste_ids = array(); 33 - $commit_names = array(); 34 - $vote_ids = array(); 35 - $file_ids = array(); 37 + if (preg_match_all($pattern, $message, $matches, PREG_SET_ORDER)) { 38 + foreach ($matches as $match) { 39 + switch ($match[1]) { 40 + case 'R2D2': 41 + $output[$match[1]] = pht('beep hoop bop'); 42 + break; 43 + } 44 + } 45 + } 46 + 47 + $pattern = 48 + '@'. 49 + '(?<!/)(?:^|\b)'. // Negative lookbehind prevent matching "/D123". 50 + '([A-Z])(\d+)'. 51 + '(?:\b|$)'. 52 + '@'; 36 53 37 54 if (preg_match_all($pattern, $message, $matches, PREG_SET_ORDER)) { 38 55 foreach ($matches as $match) { 39 56 switch ($match[1]) { 40 - case 'D': 41 - $revision_ids[] = $match[2]; 42 - break; 43 - case 'T': 44 - $task_ids[] = $match[2]; 45 - break; 46 - case 'P': 47 - $paste_ids[] = $match[2]; 48 - break; 49 - case 'V': 50 - $vote_ids[] = $match[2]; 51 - break; 52 - case 'F': 53 - $file_ids[] = $match[2]; 54 - break; 57 + case 'P': 58 + $paste_ids[] = $match[2]; 59 + break; 60 + case 'V': 61 + $vote_ids[] = $match[2]; 62 + break; 63 + case 'F': 64 + $file_ids[] = $match[2]; 65 + break; 66 + default: 67 + $name = $match[1].$match[2]; 68 + switch ($name) { 69 + case 'T1000': 70 + $output[$name] = pht( 71 + 'T1000: A mimetic poly-alloy assassin controlled by '. 72 + 'Skynet'); 73 + break; 74 + default: 75 + $object_names[] = $name; 76 + break; 77 + } 78 + break; 55 79 } 56 80 } 57 81 } ··· 68 92 } 69 93 } 70 94 71 - $output = array(); 72 - 73 - if ($revision_ids) { 74 - $revisions = $this->getConduit()->callMethodSynchronous( 75 - 'differential.query', 95 + if ($object_names) { 96 + $objects = $this->getConduit()->callMethodSynchronous( 97 + 'phid.lookup', 76 98 array( 77 - 'ids' => $revision_ids, 99 + 'names' => $object_names, 78 100 )); 79 - $revisions = array_select_keys( 80 - ipull($revisions, null, 'id'), 81 - $revision_ids); 82 - foreach ($revisions as $revision) { 83 - $output[$revision['phid']] = 84 - 'D'.$revision['id'].' '.$revision['title'].' - '. 85 - $revision['uri']; 86 - } 87 - } 88 - 89 - if ($task_ids) { 90 - foreach ($task_ids as $task_id) { 91 - if ($task_id == 1000) { 92 - $output[1000] = 'T1000: A nanomorph mimetic poly-alloy' 93 - .'(liquid metal) assassin controlled by Skynet: ' 94 - .'http://en.wikipedia.org/wiki/T-1000'; 95 - continue; 96 - } 97 - $task = $this->getConduit()->callMethodSynchronous( 98 - 'maniphest.info', 99 - array( 100 - 'task_id' => $task_id, 101 - )); 102 - $output[$task['phid']] = 'T'.$task['id'].': '.$task['title']. 103 - ' (Priority: '.$task['priority'].') - '.$task['uri']; 101 + foreach ($objects as $object) { 102 + $output[$object['phid']] = $object['fullName'].' - '.$object['uri']; 104 103 } 105 104 } 106 105