From 6ff1354ac1ff053532e85660f74216a9b57be5cd Mon Sep 17 00:00:00 2001 From: Chad Little Date: Tue, 13 Oct 2015 09:09:07 -0700 Subject: [PATCH] Fix errors when mentioning others in Ponder Summary: Fixes T9552. We need to set a questionID and the question object (for policy) when initializing a new Answer. Test Plan: Write an answer that mentions another user. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9552 Differential Revision: https://secure.phabricator.com/D14263 --- .../ponder/controller/PonderAnswerSaveController.php | 2 +- src/applications/ponder/storage/PonderAnswer.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/applications/ponder/controller/PonderAnswerSaveController.php b/src/applications/ponder/controller/PonderAnswerSaveController.php index 3953fed23f..cac17acbed 100644 --- a/src/applications/ponder/controller/PonderAnswerSaveController.php +++ b/src/applications/ponder/controller/PonderAnswerSaveController.php @@ -32,7 +32,7 @@ final class PonderAnswerSaveController extends PonderController { return id(new AphrontDialogResponse())->setDialog($dialog); } - $answer = PonderAnswer::initializeNewAnswer($viewer); + $answer = PonderAnswer::initializeNewAnswer($viewer, $question); // Question Editor diff --git a/src/applications/ponder/storage/PonderAnswer.php b/src/applications/ponder/storage/PonderAnswer.php index 2c8aff23da..722fee8eec 100644 --- a/src/applications/ponder/storage/PonderAnswer.php +++ b/src/applications/ponder/storage/PonderAnswer.php @@ -26,15 +26,18 @@ final class PonderAnswer extends PonderDAO private $userVotes = array(); - public static function initializeNewAnswer(PhabricatorUser $actor) { + public static function initializeNewAnswer( + PhabricatorUser $actor, + PonderQuestion $question) { $app = id(new PhabricatorApplicationQuery()) ->setViewer($actor) ->withClasses(array('PhabricatorPonderApplication')) ->executeOne(); return id(new PonderAnswer()) - ->setQuestionID(0) + ->setQuestionID($question->getID()) ->setContent('') + ->attachQuestion($question) ->setAuthorPHID($actor->getPHID()) ->setVoteCount(0) ->setStatus(PonderAnswerStatus::ANSWER_STATUS_VISIBLE);