@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

Remove "PhabricatorEventType::TYPE_DIFFUSION_LOOKUPUSER" event

Summary: Ref T13444. This is an ancient event and part of the old event system. It is not likely to be in use anymore, and repository identities should generally replace it nowadays anyway.

Test Plan: Grepped for constant and related methods, no longer found any hits.

Maniphest Tasks: T13444

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

+8 -66
+8 -33
src/applications/diffusion/query/DiffusionResolveUserQuery.php
··· 8 8 final class DiffusionResolveUserQuery extends Phobject { 9 9 10 10 private $name; 11 - private $commit; 12 11 13 12 public function withName($name) { 14 13 $this->name = $name; 15 14 return $this; 16 15 } 17 16 18 - public function withCommit($commit) { 19 - $this->commit = $commit; 20 - return $this; 21 - } 22 - 23 17 public function execute() { 24 - $user_name = $this->name; 25 - 26 - $phid = $this->findUserPHID($this->name); 27 - $phid = $this->fireLookupEvent($phid); 28 - 29 - return $phid; 18 + return $this->findUserPHID($this->name); 30 19 } 31 20 32 21 private function findUserPHID($user_name) { ··· 75 64 } 76 65 77 66 78 - /** 79 - * Emit an event so installs can do custom lookup of commit authors who may 80 - * not be naturally resolvable. 81 - */ 82 - private function fireLookupEvent($guess) { 83 - 84 - $type = PhabricatorEventType::TYPE_DIFFUSION_LOOKUPUSER; 85 - $data = array( 86 - 'commit' => $this->commit, 87 - 'query' => $this->name, 88 - 'result' => $guess, 89 - ); 90 - 91 - $event = new PhabricatorEvent($type, $data); 92 - PhutilEventEngine::dispatchEvent($event); 93 - 94 - return $event->getValue('result'); 95 - } 96 - 97 - 98 67 private function findUserByUserName($user_name) { 99 68 $by_username = id(new PhabricatorUser())->loadOneWhere( 100 69 'userName = %s', 101 70 $user_name); 71 + 102 72 if ($by_username) { 103 73 return $by_username->getPHID(); 104 74 } 75 + 105 76 return null; 106 77 } 107 78 ··· 112 83 $by_realname = id(new PhabricatorUser())->loadAllWhere( 113 84 'realName = %s', 114 85 $real_name); 86 + 115 87 if (count($by_realname) == 1) { 116 - return reset($by_realname)->getPHID(); 88 + return head($by_realname)->getPHID(); 117 89 } 90 + 118 91 return null; 119 92 } 120 93 121 94 122 95 private function findUserByEmailAddress($email_address) { 123 96 $by_email = PhabricatorUser::loadOneWithEmailAddress($email_address); 97 + 124 98 if ($by_email) { 125 99 return $by_email->getPHID(); 126 100 } 101 + 127 102 return null; 128 103 } 129 104
-1
src/applications/repository/management/PhabricatorRepositoryManagementLookupUsersWorkflow.php
··· 99 99 100 100 private function resolveUser(PhabricatorRepositoryCommit $commit, $name) { 101 101 $phid = id(new DiffusionResolveUserQuery()) 102 - ->withCommit($commit) 103 102 ->withName($name) 104 103 ->execute(); 105 104
-1
src/applications/repository/management/PhabricatorRepositoryManagementRebuildIdentitiesWorkflow.php
··· 101 101 if (empty($seen[$identity_key])) { 102 102 try { 103 103 $user_phid = id(new DiffusionResolveUserQuery()) 104 - ->withCommit($commit) 105 104 ->withName($identity_name) 106 105 ->execute(); 107 106
-1
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 182 182 $user_name) { 183 183 184 184 return id(new DiffusionResolveUserQuery()) 185 - ->withCommit($commit) 186 185 ->withName($user_name) 187 186 ->execute(); 188 187 }
-29
src/docs/user/userguide/events.diviner
··· 159 159 - `repository` The @{class:PhabricatorRepository} the commit was discovered 160 160 in. 161 161 162 - == Diffusion: Lookup User == 163 - 164 - The constant for this event is 165 - `PhabricatorEventType::TYPE_DIFFUSION_LOOKUPUSER`. 166 - 167 - This event is dispatched when the daemons are trying to link a commit to a 168 - Phabricator user account. You can listen for it to improve the accuracy of 169 - associating users with their commits. 170 - 171 - By default, Phabricator will try to find matches based on usernames, real names, 172 - or email addresses, but this can result in incorrect matches (e.g., if you have 173 - several employees with the same name) or failures to match (e.g., if someone 174 - changed their email address). Listening for this event allows you to intercept 175 - the lookup and supplement the results from another datasource. 176 - 177 - Data available on this event: 178 - 179 - - `commit` The @{class:PhabricatorRepositoryCommit} that data is being looked 180 - up for. 181 - - `query` The author or committer string being looked up. This will usually 182 - be something like "Abraham Lincoln <alincoln@logcabin.example.com>", but 183 - comes from the commit metadata so it may not be well-formatted. 184 - - `result` The current result from the lookup (Phabricator's best guess at 185 - the user PHID of the user named in the "query"). To substitute the result 186 - with a different result, replace this with the correct PHID in your event 187 - listener. 188 - 189 - Using @{class@libphutil:PhutilEmailAddress} may be helpful in parsing the query. 190 - 191 162 == Test: Did Run Test == 192 163 193 164 The constant for this event is
-1
src/infrastructure/events/constant/PhabricatorEventType.php
··· 9 9 const TYPE_DIFFERENTIAL_WILLMARKGENERATED = 'differential.willMarkGenerated'; 10 10 11 11 const TYPE_DIFFUSION_DIDDISCOVERCOMMIT = 'diffusion.didDiscoverCommit'; 12 - const TYPE_DIFFUSION_LOOKUPUSER = 'diffusion.lookupUser'; 13 12 14 13 const TYPE_TEST_DIDRUNTEST = 'test.didRunTest'; 15 14