@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.

Centralize "this is the current user for the request" code

Summary:
Ref T11098. This primarily fixes Conduit calls to `*.edit` methods failing when trying to access user preferences.

(The actual access is a little weird, since it seems like we're building some UI stuff inside a policy query, but that's an issue for another time.)

To fix this, consolidate the "we're about to run some kind of request with this user" code and run it consistently for web, conduit, and SSH sessions.

Additionally, make sure we swap things to the user's translation.

Test Plan:
- Ran `maniphest.edit` via `arc call-conduit`, no more settings exception.
- Set translation to ALL CAPS, got all caps output from `ssh` and Conduit.

Reviewers: avivey, chad

Reviewed By: chad

Maniphest Tasks: T11098

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

+17 -2
+3
scripts/ssh/ssh-exec.php
··· 103 103 'Invalid username ("%s"). There is no user with this username.', 104 104 $user_name)); 105 105 } 106 + 107 + id(new PhabricatorAuthSessionEngine()) 108 + ->willServeRequestForUser($user); 106 109 } else if (strlen($device_name)) { 107 110 if (!$remote_address) { 108 111 throw new Exception(
+8 -1
src/applications/auth/engine/PhabricatorAuthSessionEngine.php
··· 164 164 165 165 $cache_raw = $this->filterRawCacheData($user, $types_map, $cache_raw); 166 166 $user->attachRawCacheData($cache_raw); 167 - $user->setAllowInlineCacheGeneration(true); 168 167 169 168 switch ($session_type) { 170 169 case PhabricatorAuthSession::TYPE_WEB: ··· 830 829 } 831 830 832 831 return $cache_raw; 832 + } 833 + 834 + public function willServeRequestForUser(PhabricatorUser $user) { 835 + // We allow the login user to generate any missing cache data inline. 836 + $user->setAllowInlineCacheGeneration(true); 837 + 838 + // Switch to the user's translation. 839 + PhabricatorEnv::setLocaleCode($user->getTranslation()); 833 840 } 834 841 835 842 }
+2 -1
src/applications/base/controller/PhabricatorController.php
··· 104 104 $request->setUser($user); 105 105 } 106 106 107 - PhabricatorEnv::setLocaleCode($user->getTranslation()); 107 + id(new PhabricatorAuthSessionEngine()) 108 + ->willServeRequestForUser($user); 108 109 109 110 if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) { 110 111 $dark_console = PhabricatorDarkConsoleSetting::SETTINGKEY;
+4
src/applications/conduit/controller/PhabricatorConduitAPIController.php
··· 487 487 } 488 488 489 489 $request->setUser($user); 490 + 491 + id(new PhabricatorAuthSessionEngine()) 492 + ->willServeRequestForUser($user); 493 + 490 494 return null; 491 495 } 492 496