forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorDebugController.php
39 lines (32 loc) · 1.01 KB
/
PhabricatorDebugController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* This controller eases debugging of application problems that don't repro
* locally by allowing installs to add arbitrary debugging code easily. To use
* it:
*
* - Write some diagnostic script.
* - Instruct the user to install it in `/support/debug.php`.
* - Tell them to visit `/debug/`.
*/
final class PhabricatorDebugController extends PhabricatorController {
public function shouldRequireLogin() {
return false;
}
public function processRequest() {
if (!Filesystem::pathExists($this->getDebugFilePath())) {
return new Aphront404Response();
}
$request = $this->getRequest();
$user = $request->getUser();
ob_start();
require_once $this->getDebugFilePath();
$out = ob_get_clean();
$response = new AphrontWebpageResponse();
$response->setContent(phutil_tag('pre', array(), $out));
return $response;
}
private function getDebugFilePath() {
$root = dirname(phutil_get_library_root('phabricator'));
return $root.'/support/debug.php';
}
}