From 1c088822b4d242ed17a73234ed647681af527f1f Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 8 Jul 2016 04:31:41 -0700 Subject: [PATCH] Fix a fatal when viewing a daemon task with an invalid ID Summary: Fixes T11295. Prior to this change, the "404 page" for daemon tasks fatals. This page is special cased a little bit and not a normal 404 page, because it's possible for you to click a valid link and the task to get GC'd by the time you load the page, or similar. It tries to be a little more user-friendly than a bare 404. Test Plan: - Visited `/daemon/task/1428348920328/` (any invalid ID). - Now got a nice "no such task" page. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11295 Differential Revision: https://secure.phabricator.com/D16254 --- .../PhabricatorWorkerTaskDetailController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php b/src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php index ad15d41b9d..85c2f2f87e 100644 --- a/src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php +++ b/src/applications/daemon/controller/PhabricatorWorkerTaskDetailController.php @@ -15,9 +15,13 @@ final class PhabricatorWorkerTaskDetailController $task = reset($tasks); } + $header = new PHUIHeaderView(); + if (!$task) { $title = pht('Task Does Not Exist'); + $header->setHeader(pht('Task %d Missing', $id)); + $error_view = new PHUIInfoView(); $error_view->setTitle(pht('No Such Task')); $error_view->appendChild(phutil_tag( @@ -30,11 +34,11 @@ final class PhabricatorWorkerTaskDetailController } else { $title = pht('Task %d', $task->getID()); - $header = id(new PHUIHeaderView()) - ->setHeader(pht('Task %d: %s', + $header->setHeader( + pht( + 'Task %d: %s', $task->getID(), - $task->getTaskClass())) - ->setHeaderIcon('fa-sort'); + $task->getTaskClass())); $properties = $this->buildPropertyListView($task); @@ -59,6 +63,8 @@ final class PhabricatorWorkerTaskDetailController ); } + $header->setHeaderIcon('fa-sort'); + $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb($title); $crumbs->setBorder(true);