mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 17:32:41 +01:00
14569ae491
Summary: Currently, there's no easy way for me to tell a user "run this code from the webserver and tell me what it says". Sometimes installs can add new .php files to, e.g., `webroot/rsrc/`, but this is setup-dependent and not universal. Generally I resort to saying "put this into index.php", but that's error prone and not acceptable on active installs. Add a "debug" controller so I can instead say "put this into support/debug.php, then visit /debug/". Test Plan: Visited /debug/ with and without support/debug.php files. Visited /staus/. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D5212
39 lines
1 KiB
PHP
39 lines
1 KiB
PHP
<?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(hsprintf('<pre>%s</pre>', $out));
|
|
return $response;
|
|
}
|
|
|
|
private function getDebugFilePath() {
|
|
$root = dirname(phutil_get_library_root('phabricator'));
|
|
return $root.'/support/debug.php';
|
|
}
|
|
}
|