From fd848cabbd5cbfb374c1e49ac50e479f60058ec7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 29 Dec 2011 14:01:57 -0800 Subject: [PATCH] Improve feed robustness for Maniphest Summary: Rendering of "up for grabs" stories is wrong and sometimes fatals. Test Plan: With @skrul. --- .../feed/story/base/PhabricatorFeedStory.php | 14 ++++++++ .../PhabricatorFeedStoryManiphest.php | 35 ++++++++++++------- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/applications/feed/story/base/PhabricatorFeedStory.php b/src/applications/feed/story/base/PhabricatorFeedStory.php index a6828d16c5..7cdb665dee 100644 --- a/src/applications/feed/story/base/PhabricatorFeedStory.php +++ b/src/applications/feed/story/base/PhabricatorFeedStory.php @@ -51,6 +51,20 @@ abstract class PhabricatorFeedStory { return $this->handles; } + final protected function getHandle($phid) { + if (isset($this->handles[$phid])) { + if ($this->handles[$phid] instanceof PhabricatorObjectHandle) { + return $this->handles[$phid]; + } + } + + $handle = new PhabricatorObjectHandle(); + $handle->setPHID($phid); + $handle->setName("Unloaded Object '{$phid}'"); + + return $handle; + } + final protected function getObjects() { return $this->objects; } diff --git a/src/applications/feed/story/maniphest/PhabricatorFeedStoryManiphest.php b/src/applications/feed/story/maniphest/PhabricatorFeedStoryManiphest.php index a5a45a52e4..91265a9d9c 100644 --- a/src/applications/feed/story/maniphest/PhabricatorFeedStoryManiphest.php +++ b/src/applications/feed/story/maniphest/PhabricatorFeedStoryManiphest.php @@ -20,11 +20,12 @@ class PhabricatorFeedStoryManiphest extends PhabricatorFeedStory { public function getRequiredHandlePHIDs() { $data = $this->getStoryData(); - return array( - $this->getStoryData()->getAuthorPHID(), - $data->getValue('taskPHID'), - $data->getValue('ownerPHID'), - ); + return array_filter( + array( + $this->getStoryData()->getAuthorPHID(), + $data->getValue('taskPHID'), + $data->getValue('ownerPHID'), + )); } public function getRequiredObjectPHIDs() { @@ -36,7 +37,6 @@ class PhabricatorFeedStoryManiphest extends PhabricatorFeedStory { public function renderView() { $data = $this->getStoryData(); - $handles = $this->getHandles(); $author_phid = $data->getAuthorPHID(); $owner_phid = $data->getValue('ownerPHID'); $task_phid = $data->getValue('taskPHID'); @@ -47,18 +47,27 @@ class PhabricatorFeedStoryManiphest extends PhabricatorFeedStory { $view = new PhabricatorFeedStoryView(); $verb = ManiphestAction::getActionPastTenseVerb($action); - $title = - ''.$handles[$author_phid]->renderLink().''. - " {$verb} task ". - ''.$handles[$task_phid]->renderLink().''; + $extra = null; switch ($action) { case ManiphestAction::ACTION_ASSIGN: - $title .= - ' to '. - ''.$handles[$owner_phid]->renderLink().''; + if ($owner_phid) { + $extra = + ' to '. + ''.$this->getHandle($owner_phid)->renderLink().''; + } else { + $verb = 'placed'; + $extra = ' up for grabs'; + } break; } + + $title = + ''.$this->getHandle($author_phid)->renderLink().''. + " {$verb} task ". + ''.$this->getHandle($task_phid)->renderLink().''; + $title .= $extra; $title .= '.'; + $view->setTitle($title); switch ($action) {