@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<?php
2
3final class PhabricatorXHProfProfileController
4 extends PhabricatorXHProfController {
5
6 public function shouldAllowPublic() {
7 return true;
8 }
9
10 public function handleRequest(AphrontRequest $request) {
11 $phid = $request->getURIData('phid');
12
13 $file = id(new PhabricatorFileQuery())
14 ->setViewer($request->getUser())
15 ->withPHIDs(array($phid))
16 ->executeOne();
17 if (!$file) {
18 return new Aphront404Response();
19 }
20
21 $data = $file->loadFileData();
22 try {
23 $data = phutil_json_decode($data);
24 } catch (PhutilJSONParserException $ex) {
25 throw new Exception(
26 pht('Failed to unserialize XHProf profile!'),
27 0,
28 $ex);
29 }
30
31 $symbol = $request->getStr('symbol');
32
33 $is_framed = $request->getBool('frame');
34
35 if ($symbol) {
36 $view = new PhabricatorXHProfProfileSymbolView();
37 $view->setSymbol($symbol);
38 } else {
39 $view = new PhabricatorXHProfProfileTopLevelView();
40 $view->setFile($file);
41 $view->setLimit(100);
42 }
43
44 $view->setBaseURI($request->getRequestURI()->getPath());
45 $view->setIsFramed($is_framed);
46 $view->setProfileData($data);
47
48 $crumbs = $this->buildApplicationCrumbs();
49 $crumbs->addTextCrumb(pht('%s Profile', $symbol));
50
51 $title = pht('Profile');
52
53 return $this->newPage()
54 ->setTitle($title)
55 ->setCrumbs($crumbs)
56 ->setFrameable(true)
57 ->setShowChrome(false)
58 ->setDisableConsole(true)
59 ->appendChild($view);
60 }
61}