@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 PhabricatorXHProfSample
4 extends PhabricatorXHProfDAO
5 implements PhabricatorPolicyInterface {
6
7 protected $filePHID;
8 protected $usTotal;
9 protected $sampleRate;
10 protected $hostname;
11 protected $requestPath;
12 protected $controller;
13 protected $userPHID;
14
15 public static function initializeNewSample() {
16 return id(new self())
17 ->setUsTotal(0)
18 ->setSampleRate(0);
19 }
20
21 protected function getConfiguration() {
22 return array(
23 self::CONFIG_COLUMN_SCHEMA => array(
24 'sampleRate' => 'uint32',
25 'usTotal' => 'uint64',
26 'hostname' => 'text255?',
27 'requestPath' => 'text255?',
28 'controller' => 'text255?',
29 'userPHID' => 'phid?',
30 ),
31 self::CONFIG_KEY_SCHEMA => array(
32 'filePHID' => array(
33 'columns' => array('filePHID'),
34 'unique' => true,
35 ),
36 ),
37 ) + parent::getConfiguration();
38 }
39
40 public function getURI() {
41 return '/xhprof/profile/'.$this->getFilePHID().'/';
42 }
43
44 public function getDisplayName() {
45 $request_path = $this->getRequestPath();
46 if (phutil_nonempty_string($request_path)) {
47 return $request_path;
48 }
49
50 return pht('Unnamed Sample');
51 }
52
53
54/* -( PhabricatorPolicyInterface )----------------------------------------- */
55
56
57 public function getCapabilities() {
58 return array(
59 PhabricatorPolicyCapability::CAN_VIEW,
60 );
61 }
62
63 public function getPolicy($capability) {
64 switch ($capability) {
65 case PhabricatorPolicyCapability::CAN_VIEW:
66 return PhabricatorPolicies::getMostOpenPolicy();
67 }
68 }
69
70 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
71 return false;
72 }
73
74}