@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Clean up more PonderQuestionQuery cruft

Summary: Ref T3578. Unroll these static methods for consistency.

Test Plan: grep

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3578

Differential Revision: https://secure.phabricator.com/D6602

+34 -44
+7 -5
src/applications/ponder/controller/PonderAnswerPreviewController.php
··· 4 4 extends PonderController { 5 5 6 6 public function processRequest() { 7 - 8 7 $request = $this->getRequest(); 9 - $user = $request->getUser(); 8 + $viewer = $request->getUser(); 10 9 $question_id = $request->getInt('question_id'); 11 10 12 - $question = PonderQuestionQuery::loadSingle($user, $question_id); 11 + $question = id(new PonderQuestionQuery()) 12 + ->setViewer($viewer) 13 + ->withIDs(array($question_id)) 14 + ->executeOne(); 13 15 if (!$question) { 14 16 return new Aphront404Response(); 15 17 } 16 18 17 - $author_phid = $user->getPHID(); 19 + $author_phid = $viewer->getPHID(); 18 20 $object_phids = array($author_phid); 19 21 $handles = $this->loadViewerHandles($object_phids); 20 22 ··· 27 29 ->setQuestion($question) 28 30 ->setTarget($answer) 29 31 ->setPreview(true) 30 - ->setUser($user) 32 + ->setUser($viewer) 31 33 ->setHandles($handles) 32 34 ->setAction(PonderLiterals::LITERAL_ANSWERED); 33 35
+15 -13
src/applications/ponder/controller/PonderAnswerSaveController.php
··· 4 4 5 5 public function processRequest() { 6 6 $request = $this->getRequest(); 7 + $viewer = $request->getUser(); 8 + 7 9 if (!$request->isFormPost()) { 8 10 return new Aphront400Response(); 9 11 } 10 12 11 - $user = $request->getUser(); 12 13 $question_id = $request->getInt('question_id'); 13 - $question = PonderQuestionQuery::loadSingle($user, $question_id); 14 - 14 + $question = id(new PonderQuestionQuery()) 15 + ->setViewer($viewer) 16 + ->withIDs(array($question_id)) 17 + ->executeOne(); 15 18 if (!$question) { 16 19 return new Aphront404Response(); 17 20 } 18 21 19 22 $answer = $request->getStr('answer'); 20 23 21 - // Only want answers with some non whitespace content 22 24 if (!strlen(trim($answer))) { 23 - $dialog = new AphrontDialogView(); 24 - $dialog->setUser($request->getUser()); 25 - $dialog->setTitle(pht('Empty Answer')); 26 - $dialog->appendChild( 27 - phutil_tag('p', array(), pht( 28 - 'Your answer must not be empty.'))); 29 - $dialog->addCancelButton('/Q'.$question_id); 25 + $dialog = id(new AphrontDialogView()) 26 + ->setUser($viewer) 27 + ->setTitle(pht('Empty Answer')) 28 + ->appendChild( 29 + phutil_tag('p', array(), pht( 30 + 'Your answer must not be empty.'))) 31 + ->addCancelButton('/Q'.$question_id); 30 32 31 33 return id(new AphrontDialogResponse())->setDialog($dialog); 32 34 } ··· 40 42 $res = new PonderAnswer(); 41 43 $res 42 44 ->setContent($answer) 43 - ->setAuthorPHID($user->getPHID()) 45 + ->setAuthorPHID($viewer->getPHID()) 44 46 ->setVoteCount(0) 45 47 ->setQuestionID($question_id) 46 48 ->setContentSource($content_source); 47 49 48 50 id(new PonderAnswerEditor()) 49 - ->setActor($user) 51 + ->setActor($viewer) 50 52 ->setQuestion($question) 51 53 ->setAnswer($res) 52 54 ->saveAnswer();
+4 -2
src/applications/ponder/controller/PonderCommentSaveController.php
··· 10 10 11 11 $user = $request->getUser(); 12 12 $question_id = $request->getInt('question_id'); 13 - $question = PonderQuestionQuery::loadSingle($user, $question_id); 14 - 13 + $question = id(new PonderQuestionQuery()) 14 + ->setViewer($user) 15 + ->withIDs(array($question_id)) 16 + ->executeOne(); 15 17 if (!$question) { 16 18 return new Aphront404Response(); 17 19 }
+4 -1
src/applications/ponder/controller/PonderQuestionViewController.php
··· 13 13 $request = $this->getRequest(); 14 14 $user = $request->getUser(); 15 15 16 - $question = PonderQuestionQuery::loadSingle($user, $this->questionID); 16 + $question = id(new PonderQuestionQuery()) 17 + ->setViewer($user) 18 + ->withIDs(array($this->questionID)) 19 + ->executeOne(); 17 20 if (!$question) { 18 21 return new Aphront404Response(); 19 22 }
+4 -1
src/applications/ponder/controller/PonderVoteSaveController.php
··· 21 21 $target = null; 22 22 23 23 if ($this->kind == "question") { 24 - $target = PonderQuestionQuery::loadSingleByPHID($user, $phid); 24 + $target = id(new PonderQuestionQuery()) 25 + ->setViewer($user) 26 + ->withPHIDs(array($phid)) 27 + ->executeOne(); 25 28 } else if ($this->kind == "answer") { 26 29 $target = id(new PonderAnswerQuery()) 27 30 ->setViewer($user)
-22
src/applications/ponder/query/PonderQuestionQuery.php
··· 47 47 return $this; 48 48 } 49 49 50 - public static function loadSingle($viewer, $id) { 51 - if (!$viewer) { 52 - throw new Exception("Must set viewer when calling loadSingle"); 53 - } 54 - 55 - return idx(id(new PonderQuestionQuery()) 56 - ->setViewer($viewer) 57 - ->withIDs(array($id)) 58 - ->execute(), $id); 59 - } 60 - 61 - public static function loadSingleByPHID($viewer, $phid) { 62 - if (!$viewer) { 63 - throw new Exception("Must set viewer when calling loadSingle"); 64 - } 65 - 66 - return array_shift(id(new PonderQuestionQuery()) 67 - ->withPHIDs(array($phid)) 68 - ->setViewer($viewer) 69 - ->execute()); 70 - } 71 - 72 50 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 73 51 $where = array(); 74 52