@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 some PonderAnswer / PonderAnswerQuery cruft

Summary: Ref T3578. Ref T2715. Clean up some cruft so we can use Application PHIDs for "ANSW" and eventually unbeta Ponder.

Test Plan: Grep, voted on an answer.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2715, T3578

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

+19 -45
+4 -1
src/applications/ponder/controller/PonderVoteSaveController.php
··· 23 23 if ($this->kind == "question") { 24 24 $target = PonderQuestionQuery::loadSingleByPHID($user, $phid); 25 25 } else if ($this->kind == "answer") { 26 - $target = PonderAnswerQuery::loadSingleByPHID($user, $phid); 26 + $target = id(new PonderAnswerQuery()) 27 + ->setViewer($user) 28 + ->withPHID($phid) 29 + ->executeOne(); 27 30 } 28 31 29 32 if (!$target) {
+15 -32
src/applications/ponder/query/PonderAnswerQuery.php
··· 7 7 private $authorPHID; 8 8 private $orderNewest; 9 9 10 + private $viewer; 11 + 12 + public function setViewer(PhabricatorUser $viewer) { 13 + $this->viewer = $viewer; 14 + return $this; 15 + } 16 + 17 + public function getViewer() { 18 + return $this->viewer; 19 + } 20 + 21 + public function executeOne() { 22 + return head($this->execute()); 23 + } 24 + 10 25 public function withID($qid) { 11 26 $this->id = $qid; 12 27 return $this; ··· 25 40 public function orderByNewest($usethis) { 26 41 $this->orderNewest = $usethis; 27 42 return $this; 28 - } 29 - 30 - public static function loadByAuthor($viewer, $author_phid, $offset, $count) { 31 - if (!$viewer) { 32 - throw new Exception("Must set viewer when calling loadByAuthor"); 33 - } 34 - 35 - return id(new PonderAnswerQuery()) 36 - ->withAuthorPHID($author_phid) 37 - ->setOffset($offset) 38 - ->setLimit($count) 39 - ->orderByNewest(true) 40 - ->execute(); 41 - } 42 - 43 - public static function loadSingle($viewer, $id) { 44 - if (!$viewer) { 45 - throw new Exception("Must set viewer when calling loadSingle"); 46 - } 47 - return idx(id(new PonderAnswerQuery()) 48 - ->withID($id) 49 - ->execute(), $id); 50 - } 51 - 52 - public static function loadSingleByPHID($viewer, $phid) { 53 - if (!$viewer) { 54 - throw new Exception("Must set viewer when calling loadSingle"); 55 - } 56 - 57 - return array_shift(id(new PonderAnswerQuery()) 58 - ->withPHID($phid) 59 - ->execute()); 60 43 } 61 44 62 45 private function buildWhereClause($conn_r) {
-12
src/applications/ponder/storage/PonderAnswer.php
··· 53 53 ) + parent::getConfiguration(); 54 54 } 55 55 56 - public function setTitle($title) { 57 - $this->title = $title; 58 - if (!$this->getID()) { 59 - $this->originalTitle = $title; 60 - } 61 - return $this; 62 - } 63 - 64 56 public function generatePHID() { 65 57 return PhabricatorPHID::generateNewPHID( 66 58 PhabricatorPHIDConstants::PHID_TYPE_ANSW); ··· 73 65 74 66 public function getContentSource() { 75 67 return PhabricatorContentSource::newFromSerialized($this->contentSource); 76 - } 77 - 78 - public function getAnswers() { 79 - return $this->loadRelatives(new PonderAnswer(), "questionID"); 80 68 } 81 69 82 70 public function getMarkupField() {