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

Add an "--as" flag to "bin/conduit call ..." to improve flexibility and ease of profiling

Summary:
Ref T13164. In PHI801, an install reported a particular slow Conduit method call.

Conduit calls aren't easily profilable with normal tools (for example, `arc call-conduit --xprofile ...` gives you a profile of the //client//). They can be profiled most easily with `bin/conduit call ... --xprofile`.

However, `bin/conduit call` currently doesn't let you pick a user to execute the command on behalf of, so it's not terribly useful for profiling `*.edit`-style methods which do a write: these need a real acting user.

Test Plan:
Ran `bin/conduit call --method user.whoami --as epriestley ...` with valid, invalid, and no acting users.

```
$ echo '{}' | ./bin/conduit call --method user.whoami --as epriestley --input -
Reading input from stdin...
{
"result": {
"phid": "PHID-USER-icyixzkx3f4ttv67avbn",
"userName": "epriestley",
"realName": "Evan Priestley",
...
```

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13164

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

+24 -1
+24 -1
src/applications/conduit/management/PhabricatorConduitCallManagementWorkflow.php
··· 21 21 'File to read parameters from, or "-" to read from '. 22 22 'stdin.'), 23 23 ), 24 + array( 25 + 'name' => 'as', 26 + 'param' => 'username', 27 + 'help' => pht( 28 + 'Execute the call as the given user. (If omitted, the call will '. 29 + 'be executed as an omnipotent user.)'), 30 + ), 24 31 )); 25 32 } 26 33 ··· 39 46 pht('Specify a file to read parameters from with "--input".')); 40 47 } 41 48 49 + $as = $args->getArg('as'); 50 + if (strlen($as)) { 51 + $actor = id(new PhabricatorPeopleQuery()) 52 + ->setViewer($viewer) 53 + ->withUsernames(array($as)) 54 + ->executeOne(); 55 + if (!$actor) { 56 + throw new PhutilArgumentUsageException( 57 + pht( 58 + 'No such user "%s" exists.', 59 + $as)); 60 + } 61 + } else { 62 + $actor = $viewer; 63 + } 64 + 42 65 if ($input === '-') { 43 66 fprintf(STDERR, tsprintf("%s\n", pht('Reading input from stdin...'))); 44 67 $input_json = file_get_contents('php://stdin'); ··· 49 72 $params = phutil_json_decode($input_json); 50 73 51 74 $result = id(new ConduitCall($method, $params)) 52 - ->setUser($viewer) 75 + ->setUser($actor) 53 76 ->execute(); 54 77 55 78 $output = array(