From 5ba66e56fd54c5050c61fba4d792995071e0b0a4 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 17 Sep 2018 15:16:00 -0700 Subject: [PATCH] Fix Phriction rendering for initial install and 404 pages Summary: Depends on D19682. Ref T13202. We currently fatal when trying to render a timeline if: - an install is fresh, so there are no pages yet, and you look at "/w/"; or - you're looking at a Phriction page which doesn't exist (yet) like "/w/aadsflknadsflnf/". Rendering a timeline and comment area doesn't make sense in these cases, so don't render them. Test Plan: Hit both cases described above, got "new/empty page" prompts instead of fatals. Reviewers: amckinley Maniphest Tasks: T13202 Differential Revision: https://secure.phabricator.com/D19683 --- .../PhrictionDocumentController.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php index 77f6a3529c..8da9807064 100644 --- a/src/applications/phriction/controller/PhrictionDocumentController.php +++ b/src/applications/phriction/controller/PhrictionDocumentController.php @@ -377,16 +377,21 @@ final class PhrictionDocumentController $page_content->setCurtain($curtain); } - $timeline = $this->buildTransactionTimeline( - $document, - new PhrictionTransactionQuery()); + if ($document->getPHID()) { + $timeline = $this->buildTransactionTimeline( + $document, + new PhrictionTransactionQuery()); - $edit_engine = id(new PhrictionDocumentEditEngine()) - ->setViewer($viewer) - ->setTargetObject($document); + $edit_engine = id(new PhrictionDocumentEditEngine()) + ->setViewer($viewer) + ->setTargetObject($document); - $comment_view = $edit_engine - ->buildEditEngineCommentView($document); + $comment_view = $edit_engine + ->buildEditEngineCommentView($document); + } else { + $timeline = null; + $comment_view = null; + } return $this->newPage() ->setTitle($page_title)