From 122f643d6f3604aaa149a6b56f2ae93dea338a16 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 12 Oct 2013 17:08:47 -0700 Subject: [PATCH] Fix two issues where StandardPageView assumes it will always have access to a user Summary: If we hit an exception very early, the request may not have a user yet. Don't assume it will. Test Plan: Broke MySQL config on purpose to test some stuff, loaded Phabricator, got a nice error page instead of a super-fatal one. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7286 --- src/view/page/PhabricatorStandardPageView.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/view/page/PhabricatorStandardPageView.php b/src/view/page/PhabricatorStandardPageView.php index 4cac85a909..c7a1126e67 100644 --- a/src/view/page/PhabricatorStandardPageView.php +++ b/src/view/page/PhabricatorStandardPageView.php @@ -202,8 +202,14 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { require_celerity_resource('javelin-behavior-error-log'); } + if ($user) { + $viewer = $user; + } else { + $viewer = new PhabricatorUser(); + } + $menu = id(new PhabricatorMainMenuView()) - ->setUser($request->getUser()) + ->setUser($viewer) ->setDefaultSearchScope($this->getSearchDefaultScope()); if ($this->getController()) { @@ -345,7 +351,7 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { $user = $request->getUser(); $container = null; - if ($user->isLoggedIn()) { + if ($user && $user->isLoggedIn()) { $aphlict_object_id = celerity_generate_unique_node_id(); $aphlict_container_id = celerity_generate_unique_node_id();