diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index 5306e5bd06..a5ccd89196 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -445,8 +445,14 @@ class AphrontDefaultApplicationConfiguration $class = phutil_escape_html(get_class($ex)); $message = phutil_escape_html($ex->getMessage()); + $user = $this->getRequest()->getUser(); + if (!$user) { + // If we hit an exception very early, we won't have a user. + $user = new PhabricatorUser(); + } + if (PhabricatorEnv::getEnvConfig('phabricator.show-stack-traces')) { - $trace = $this->renderStackTrace($ex->getTrace()); + $trace = $this->renderStackTrace($ex->getTrace(), $user); } else { $trace = null; } @@ -457,12 +463,6 @@ class AphrontDefaultApplicationConfiguration $trace. ''; - $user = $this->getRequest()->getUser(); - if (!$user) { - // If we hit an exception very early, we won't have a user. - $user = new PhabricatorUser(); - } - $dialog = new AphrontDialogView(); $dialog ->setTitle('Unhandled Exception ("'.$class.'")') @@ -525,20 +525,17 @@ class AphrontDefaultApplicationConfiguration )); } - private function renderStackTrace($trace) { + private function renderStackTrace($trace, PhabricatorUser $user) { $libraries = PhutilBootloader::getInstance()->getAllLibraries(); // TODO: Make this configurable? - $host = 'https://secure.phabricator.com'; + $path = 'https://secure.phabricator.com/diffusion/%s/browse/master/src/'; - $browse = array( - 'arcanist' => - $host.'/diffusion/ARC/browse/master/src/', - 'phutil' => - $host.'/diffusion/PHU/browse/master/src/', - 'phabricator' => - $host.'/diffusion/P/browse/master/src/', + $callsigns = array( + 'arcanist' => 'ARC', + 'phutil' => 'PHU', + 'phabricator' => 'P', ); $rows = array(); @@ -565,14 +562,22 @@ class AphrontDefaultApplicationConfiguration } if ($file) { - if (isset($browse[$lib])) { + if (isset($callsigns[$lib])) { + $attrs = array( + 'href' => $user->loadEditorLink( + '/src/'.$relative, + $part['line'], + $callsigns[$lib]), + 'title' => $file, + ); + if (!$attrs['href']) { + $attrs['href'] = sprintf($path, $callsigns[$lib]). + $relative.'$'.$part['line']; + $attrs['target'] = '_blank'; + } $file_name = phutil_render_tag( 'a', - array( - 'href' => $browse[$lib].$relative.'$'.$part['line'], - 'title' => $file, - 'target' => '_blank', - ), + $attrs, phutil_escape_html($relative)); } else { $file_name = phutil_render_tag( diff --git a/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php b/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php index 828af226e8..74eb6abeb6 100644 --- a/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php +++ b/src/applications/differential/view/changesetlistview/DifferentialChangesetListView.php @@ -256,7 +256,8 @@ final class DifferentialChangesetListView extends AphrontView { $changeset->getAbsoluteRepositoryPath($this->diff, $repository), '/'); $line = 1; // TODO: get first changed line - $editor_link = $user->loadEditorLink($path, $line, $repository); + $callsign = $repository->getCallsign(); + $editor_link = $user->loadEditorLink($path, $line, $callsign); if ($editor_link) { $meta['editor'] = $editor_link; } else { diff --git a/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php b/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php index 378a499e3b..5a95105e40 100644 --- a/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php +++ b/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php @@ -200,7 +200,7 @@ final class DifferentialDiffTableOfContentsView extends AphrontView { $editor_link = $this->user->loadEditorLink( implode(' ', $paths), 1, // line number - $this->repository); + $this->repository->getCallsign()); if ($editor_link) { $editor_link = phutil_render_tag( 'a', diff --git a/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php index c78c106dcd..187cd280eb 100644 --- a/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php +++ b/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php @@ -221,7 +221,8 @@ final class DiffusionBrowseFileController extends DiffusionController { $path = $drequest->getPath(); $line = 1; - $editor_link = $user->loadEditorLink($path, $line, $repository); + $callsign = $repository->getCallsign(); + $editor_link = $user->loadEditorLink($path, $line, $callsign); if (!$editor_link) { return null; } diff --git a/src/applications/people/storage/user/PhabricatorUser.php b/src/applications/people/storage/user/PhabricatorUser.php index 062afc280f..14b171e784 100644 --- a/src/applications/people/storage/user/PhabricatorUser.php +++ b/src/applications/people/storage/user/PhabricatorUser.php @@ -413,16 +413,14 @@ final class PhabricatorUser extends PhabricatorUserDAO { return $preferences; } - public function loadEditorLink($path, - $line, - PhabricatorRepository $repository) { + public function loadEditorLink($path, $line, $callsign) { $editor = $this->loadPreferences()->getPreference( PhabricatorUserPreferences::PREFERENCE_EDITOR); if ($editor) { return strtr($editor, array( '%f' => phutil_escape_uri($path), '%l' => phutil_escape_uri($line), - '%r' => phutil_escape_uri($repository->getCallsign()), + '%r' => phutil_escape_uri($callsign), )); } }