@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 a user-accessible hook for dumping debug code into an install

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

+47 -1
+3
.gitignore
··· 27 27 28 28 # Impact Font 29 29 /resources/font/impact.ttf 30 + 31 + # User-accessible hook for adhoc debugging scripts 32 + /support/debug.php
+3 -1
src/__phutil_library_map__.php
··· 831 831 'PhabricatorDaemonLogListView' => 'applications/daemon/view/PhabricatorDaemonLogListView.php', 832 832 'PhabricatorDaemonLogViewController' => 'applications/daemon/controller/PhabricatorDaemonLogViewController.php', 833 833 'PhabricatorDaemonReference' => 'infrastructure/daemon/control/PhabricatorDaemonReference.php', 834 + 'PhabricatorDebugController' => 'applications/system/PhabricatorDebugController.php', 834 835 'PhabricatorDefaultFileStorageEngineSelector' => 'applications/files/engineselector/PhabricatorDefaultFileStorageEngineSelector.php', 835 836 'PhabricatorDefaultSearchEngineSelector' => 'applications/search/selector/PhabricatorDefaultSearchEngineSelector.php', 836 837 'PhabricatorDeveloperConfigOptions' => 'applications/config/option/PhabricatorDeveloperConfigOptions.php', ··· 1307 1308 'PhabricatorSortTableExample' => 'applications/uiexample/examples/PhabricatorSortTableExample.php', 1308 1309 'PhabricatorSourceCodeView' => 'view/layout/PhabricatorSourceCodeView.php', 1309 1310 'PhabricatorStandardPageView' => 'view/page/PhabricatorStandardPageView.php', 1310 - 'PhabricatorStatusController' => 'applications/status/PhabricatorStatusController.php', 1311 + 'PhabricatorStatusController' => 'applications/system/PhabricatorStatusController.php', 1311 1312 'PhabricatorStorageFixtureScopeGuard' => 'infrastructure/testing/fixture/PhabricatorStorageFixtureScopeGuard.php', 1312 1313 'PhabricatorStorageManagementAPI' => 'infrastructure/storage/management/PhabricatorStorageManagementAPI.php', 1313 1314 'PhabricatorStorageManagementDatabasesWorkflow' => 'infrastructure/storage/management/workflow/PhabricatorStorageManagementDatabasesWorkflow.php', ··· 2337 2338 'PhabricatorDaemonLogListController' => 'PhabricatorDaemonController', 2338 2339 'PhabricatorDaemonLogListView' => 'AphrontView', 2339 2340 'PhabricatorDaemonLogViewController' => 'PhabricatorDaemonController', 2341 + 'PhabricatorDebugController' => 'PhabricatorController', 2340 2342 'PhabricatorDefaultFileStorageEngineSelector' => 'PhabricatorFileStorageEngineSelector', 2341 2343 'PhabricatorDefaultSearchEngineSelector' => 'PhabricatorSearchEngineSelector', 2342 2344 'PhabricatorDeveloperConfigOptions' => 'PhabricatorApplicationConfigOptions',
+2
src/aphront/configuration/AphrontDefaultApplicationConfiguration.php
··· 109 109 'testpaymentform/' => 'PhortuneStripeTestPaymentFormController', 110 110 ), 111 111 ), 112 + 113 + '/debug/' => 'PhabricatorDebugController', 112 114 ); 113 115 } 114 116
src/applications/status/PhabricatorStatusController.php src/applications/system/PhabricatorStatusController.php
+39
src/applications/system/PhabricatorDebugController.php
··· 1 + <?php 2 + 3 + /** 4 + * This controller eases debugging of application problems that don't repro 5 + * locally by allowing installs to add arbitrary debugging code easily. To use 6 + * it: 7 + * 8 + * - Write some diagnostic script. 9 + * - Instruct the user to install it in `/support/debug.php`. 10 + * - Tell them to visit `/debug/`. 11 + */ 12 + final class PhabricatorDebugController extends PhabricatorController { 13 + 14 + public function shouldRequireLogin() { 15 + return false; 16 + } 17 + 18 + public function processRequest() { 19 + if (!Filesystem::pathExists($this->getDebugFilePath())) { 20 + return new Aphront404Response(); 21 + } 22 + 23 + $request = $this->getRequest(); 24 + $user = $request->getUser(); 25 + 26 + ob_start(); 27 + require_once $this->getDebugFilePath(); 28 + $out = ob_get_clean(); 29 + 30 + $response = new AphrontWebpageResponse(); 31 + $response->setContent(hsprintf('<pre>%s</pre>', $out)); 32 + return $response; 33 + } 34 + 35 + private function getDebugFilePath() { 36 + $root = dirname(phutil_get_library_root('phabricator')); 37 + return $root.'/support/debug.php'; 38 + } 39 + }