@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.

Remove VotableInterface from PonderQuestion

Summary: Ref T6920, This removes the PonderVotableInterface from PonderQuestion and assocaited code. Also... never used?

Test Plan: Visit Ponder, See List, New Question, Add Answer.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T6920

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

+4 -311
+2
resources/sql/autopatches/20150808.ponder.vote.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_ponder.ponder_question 2 + DROP COLUMN heat;
+2
resources/sql/autopatches/20150808.ponder.vote.2.sql
··· 1 + ALTER TABLE {$NAMESPACE}_ponder.ponder_question 2 + DROP COLUMN voteCount;
-5
src/__phutil_library_map__.php
··· 3409 3409 'PonderQuestionCommentController' => 'applications/ponder/controller/PonderQuestionCommentController.php', 3410 3410 'PonderQuestionEditController' => 'applications/ponder/controller/PonderQuestionEditController.php', 3411 3411 'PonderQuestionEditor' => 'applications/ponder/editor/PonderQuestionEditor.php', 3412 - 'PonderQuestionHasVotingUserEdgeType' => 'applications/ponder/edge/PonderQuestionHasVotingUserEdgeType.php', 3413 3412 'PonderQuestionHistoryController' => 'applications/ponder/controller/PonderQuestionHistoryController.php', 3414 3413 'PonderQuestionListController' => 'applications/ponder/controller/PonderQuestionListController.php', 3415 3414 'PonderQuestionMailReceiver' => 'applications/ponder/mail/PonderQuestionMailReceiver.php', ··· 3432 3431 'PonderVoteEditor' => 'applications/ponder/editor/PonderVoteEditor.php', 3433 3432 'PonderVoteSaveController' => 'applications/ponder/controller/PonderVoteSaveController.php', 3434 3433 'PonderVotingUserHasAnswerEdgeType' => 'applications/ponder/edge/PonderVotingUserHasAnswerEdgeType.php', 3435 - 'PonderVotingUserHasQuestionEdgeType' => 'applications/ponder/edge/PonderVotingUserHasQuestionEdgeType.php', 3436 3434 'ProjectAddProjectsEmailCommand' => 'applications/project/command/ProjectAddProjectsEmailCommand.php', 3437 3435 'ProjectBoardTaskCard' => 'applications/project/view/ProjectBoardTaskCard.php', 3438 3436 'ProjectCanLockProjectsCapability' => 'applications/project/capability/ProjectCanLockProjectsCapability.php', ··· 7597 7595 'PonderDAO', 7598 7596 'PhabricatorApplicationTransactionInterface', 7599 7597 'PhabricatorMarkupInterface', 7600 - 'PonderVotableInterface', 7601 7598 'PhabricatorSubscribableInterface', 7602 7599 'PhabricatorFlaggableInterface', 7603 7600 'PhabricatorPolicyInterface', ··· 7609 7606 'PonderQuestionCommentController' => 'PonderController', 7610 7607 'PonderQuestionEditController' => 'PonderController', 7611 7608 'PonderQuestionEditor' => 'PonderEditor', 7612 - 'PonderQuestionHasVotingUserEdgeType' => 'PhabricatorEdgeType', 7613 7609 'PonderQuestionHistoryController' => 'PonderController', 7614 7610 'PonderQuestionListController' => 'PonderController', 7615 7611 'PonderQuestionMailReceiver' => 'PhabricatorObjectMailReceiver', ··· 7631 7627 'PonderVoteEditor' => 'PhabricatorEditor', 7632 7628 'PonderVoteSaveController' => 'PonderController', 7633 7629 'PonderVotingUserHasAnswerEdgeType' => 'PhabricatorEdgeType', 7634 - 'PonderVotingUserHasQuestionEdgeType' => 'PhabricatorEdgeType', 7635 7630 'ProjectAddProjectsEmailCommand' => 'MetaMTAEmailTransactionCommand', 7636 7631 'ProjectBoardTaskCard' => 'Phobject', 7637 7632 'ProjectCanLockProjectsCapability' => 'PhabricatorPolicyCapability',
-3
src/applications/ponder/controller/PonderQuestionViewController.php
··· 10 10 ->setViewer($viewer) 11 11 ->withIDs(array($id)) 12 12 ->needAnswers(true) 13 - ->needViewerVotes(true) 14 13 ->executeOne(); 15 14 if (!$question) { 16 15 return new Aphront404Response(); 17 16 } 18 - 19 - $question->attachVotes($viewer->getPHID()); 20 17 21 18 $question_xactions = $this->buildQuestionTransactions($question); 22 19 $answers = $this->buildAnswers($question->getAnswers());
-105
src/applications/ponder/edge/PonderQuestionHasVotingUserEdgeType.php
··· 1 - <?php 2 - 3 - final class PonderQuestionHasVotingUserEdgeType extends PhabricatorEdgeType { 4 - 5 - const EDGECONST = 17; 6 - 7 - public function shouldWriteInverseTransactions() { 8 - return true; 9 - } 10 - 11 - public function getInverseEdgeConstant() { 12 - return PonderVotingUserHasQuestionEdgeType::EDGECONST; 13 - } 14 - 15 - public function getTransactionAddString( 16 - $actor, 17 - $add_count, 18 - $add_edges) { 19 - 20 - return pht( 21 - '%s added %s voting user(s): %s.', 22 - $actor, 23 - $add_count, 24 - $add_edges); 25 - } 26 - 27 - public function getTransactionRemoveString( 28 - $actor, 29 - $rem_count, 30 - $rem_edges) { 31 - 32 - return pht( 33 - '%s removed %s voting user(s): %s.', 34 - $actor, 35 - $rem_count, 36 - $rem_edges); 37 - } 38 - 39 - public function getTransactionEditString( 40 - $actor, 41 - $total_count, 42 - $add_count, 43 - $add_edges, 44 - $rem_count, 45 - $rem_edges) { 46 - 47 - return pht( 48 - '%s edited %s voting user(s), added %s: %s; removed %s: %s.', 49 - $actor, 50 - $total_count, 51 - $add_count, 52 - $add_edges, 53 - $rem_count, 54 - $rem_edges); 55 - } 56 - 57 - public function getFeedAddString( 58 - $actor, 59 - $object, 60 - $add_count, 61 - $add_edges) { 62 - 63 - return pht( 64 - '%s added %s voting user(s) to %s: %s.', 65 - $actor, 66 - $add_count, 67 - $object, 68 - $add_edges); 69 - } 70 - 71 - public function getFeedRemoveString( 72 - $actor, 73 - $object, 74 - $rem_count, 75 - $rem_edges) { 76 - 77 - return pht( 78 - '%s removed %s voting user(s) from %s: %s.', 79 - $actor, 80 - $rem_count, 81 - $object, 82 - $rem_edges); 83 - } 84 - 85 - public function getFeedEditString( 86 - $actor, 87 - $object, 88 - $total_count, 89 - $add_count, 90 - $add_edges, 91 - $rem_count, 92 - $rem_edges) { 93 - 94 - return pht( 95 - '%s edited %s voting user(s) for %s, added %s: %s; removed %s: %s.', 96 - $actor, 97 - $total_count, 98 - $object, 99 - $add_count, 100 - $add_edges, 101 - $rem_count, 102 - $rem_edges); 103 - } 104 - 105 - }
-105
src/applications/ponder/edge/PonderVotingUserHasQuestionEdgeType.php
··· 1 - <?php 2 - 3 - final class PonderVotingUserHasQuestionEdgeType extends PhabricatorEdgeType { 4 - 5 - const EDGECONST = 18; 6 - 7 - public function shouldWriteInverseTransactions() { 8 - return true; 9 - } 10 - 11 - public function getInverseEdgeConstant() { 12 - return PonderQuestionHasVotingUserEdgeType::EDGECONST; 13 - } 14 - 15 - public function getTransactionAddString( 16 - $actor, 17 - $add_count, 18 - $add_edges) { 19 - 20 - return pht( 21 - '%s added %s question(s): %s.', 22 - $actor, 23 - $add_count, 24 - $add_edges); 25 - } 26 - 27 - public function getTransactionRemoveString( 28 - $actor, 29 - $rem_count, 30 - $rem_edges) { 31 - 32 - return pht( 33 - '%s removed %s question(s): %s.', 34 - $actor, 35 - $rem_count, 36 - $rem_edges); 37 - } 38 - 39 - public function getTransactionEditString( 40 - $actor, 41 - $total_count, 42 - $add_count, 43 - $add_edges, 44 - $rem_count, 45 - $rem_edges) { 46 - 47 - return pht( 48 - '%s edited %s question(s), added %s: %s; removed %s: %s.', 49 - $actor, 50 - $total_count, 51 - $add_count, 52 - $add_edges, 53 - $rem_count, 54 - $rem_edges); 55 - } 56 - 57 - public function getFeedAddString( 58 - $actor, 59 - $object, 60 - $add_count, 61 - $add_edges) { 62 - 63 - return pht( 64 - '%s added %s question(s) to %s: %s.', 65 - $actor, 66 - $add_count, 67 - $object, 68 - $add_edges); 69 - } 70 - 71 - public function getFeedRemoveString( 72 - $actor, 73 - $object, 74 - $rem_count, 75 - $rem_edges) { 76 - 77 - return pht( 78 - '%s removed %s question(s) from %s: %s.', 79 - $actor, 80 - $rem_count, 81 - $object, 82 - $rem_edges); 83 - } 84 - 85 - public function getFeedEditString( 86 - $actor, 87 - $object, 88 - $total_count, 89 - $add_count, 90 - $add_edges, 91 - $rem_count, 92 - $rem_edges) { 93 - 94 - return pht( 95 - '%s edited %s question(s) for %s, added %s: %s; removed %s: %s.', 96 - $actor, 97 - $total_count, 98 - $object, 99 - $add_count, 100 - $add_edges, 101 - $rem_count, 102 - $rem_edges); 103 - } 104 - 105 - }
-30
src/applications/ponder/query/PonderQuestionQuery.php
··· 12 12 private $needProjectPHIDs; 13 13 14 14 private $needAnswers; 15 - private $needViewerVotes; 16 15 17 16 public function withIDs(array $ids) { 18 17 $this->ids = $ids; ··· 41 40 42 41 public function needAnswers($need_answers) { 43 42 $this->needAnswers = $need_answers; 44 - return $this; 45 - } 46 - 47 - public function needViewerVotes($need_viewer_votes) { 48 - $this->needViewerVotes = $need_viewer_votes; 49 43 return $this; 50 44 } 51 45 ··· 106 100 ->setOrderVector(array('-id')) 107 101 ->withQuestionIDs(mpull($questions, 'getID')); 108 102 109 - if ($this->needViewerVotes) { 110 - $aquery->needViewerVotes($this->needViewerVotes); 111 - } 112 - 113 103 $answers = $aquery->execute(); 114 104 $answers = mgroup($answers, 'getQuestionID'); 115 105 116 106 foreach ($questions as $question) { 117 107 $question_answers = idx($answers, $question->getID(), array()); 118 108 $question->attachAnswers(mpull($question_answers, null, 'getPHID')); 119 - } 120 - } 121 - 122 - if ($this->needViewerVotes) { 123 - $viewer_phid = $this->getViewer()->getPHID(); 124 - 125 - $etype = PonderQuestionHasVotingUserEdgeType::EDGECONST; 126 - $edges = id(new PhabricatorEdgeQuery()) 127 - ->withSourcePHIDs($phids) 128 - ->withDestinationPHIDs(array($viewer_phid)) 129 - ->withEdgeTypes(array($etype)) 130 - ->needEdgeData(true) 131 - ->execute(); 132 - foreach ($questions as $question) { 133 - $user_edge = idx( 134 - $edges[$question->getPHID()][$etype], 135 - $viewer_phid, 136 - array()); 137 - 138 - $question->attachUserVote($viewer_phid, idx($user_edge, 'data', 0)); 139 109 } 140 110 } 141 111
-63
src/applications/ponder/storage/PonderQuestion.php
··· 4 4 implements 5 5 PhabricatorApplicationTransactionInterface, 6 6 PhabricatorMarkupInterface, 7 - PonderVotableInterface, 8 7 PhabricatorSubscribableInterface, 9 8 PhabricatorFlaggableInterface, 10 9 PhabricatorPolicyInterface, ··· 25 24 protected $viewPolicy; 26 25 protected $spacePHID; 27 26 28 - protected $voteCount; 29 27 protected $answerCount; 30 - protected $heat; 31 28 protected $mailKey; 32 29 33 30 private $answers; 34 - private $vote; 35 31 private $comments; 36 32 37 33 private $projectPHIDs = self::ATTACHABLE; ··· 49 45 ->setAuthorPHID($actor->getPHID()) 50 46 ->setViewPolicy($view_policy) 51 47 ->setStatus(PonderQuestionStatus::STATUS_OPEN) 52 - ->setVoteCount(0) 53 48 ->setAnswerCount(0) 54 - ->setHeat(0.0) 55 49 ->setSpacePHID($actor->getDefaultSpacePHID()); 56 50 } 57 51 ··· 60 54 self::CONFIG_AUX_PHID => true, 61 55 self::CONFIG_COLUMN_SCHEMA => array( 62 56 'title' => 'text255', 63 - 'voteCount' => 'sint32', 64 57 'status' => 'text32', 65 58 'content' => 'text', 66 - 'heat' => 'double', 67 59 'answerCount' => 'uint32', 68 60 'mailKey' => 'bytes20', 69 61 ··· 80 72 'authorPHID' => array( 81 73 'columns' => array('authorPHID'), 82 74 ), 83 - 'heat' => array( 84 - 'columns' => array('heat'), 85 - ), 86 75 'status' => array( 87 76 'columns' => array('status'), 88 77 ), ··· 103 92 return PhabricatorContentSource::newFromSerialized($this->contentSource); 104 93 } 105 94 106 - public function attachVotes($user_phid) { 107 - $qa_phids = mpull($this->answers, 'getPHID') + array($this->getPHID()); 108 - 109 - $edges = id(new PhabricatorEdgeQuery()) 110 - ->withSourcePHIDs(array($user_phid)) 111 - ->withDestinationPHIDs($qa_phids) 112 - ->withEdgeTypes( 113 - array( 114 - PonderVotingUserHasQuestionEdgeType::EDGECONST, 115 - PonderVotingUserHasAnswerEdgeType::EDGECONST, 116 - )) 117 - ->needEdgeData(true) 118 - ->execute(); 119 - 120 - $question_edge = 121 - $edges[$user_phid][PonderVotingUserHasQuestionEdgeType::EDGECONST]; 122 - $answer_edges = 123 - $edges[$user_phid][PonderVotingUserHasAnswerEdgeType::EDGECONST]; 124 - $edges = null; 125 - 126 - $this->setUserVote(idx($question_edge, $this->getPHID())); 127 - foreach ($this->answers as $answer) { 128 - $answer->setUserVote(idx($answer_edges, $answer->getPHID())); 129 - } 130 - } 131 - 132 - public function setUserVote($vote) { 133 - $this->vote = $vote['data']; 134 - if (!$this->vote) { 135 - $this->vote = PonderVote::VOTE_NONE; 136 - } 137 - return $this; 138 - } 139 - 140 - public function attachUserVote($user_phid, $vote) { 141 - $this->vote = $vote; 142 - return $this; 143 - } 144 - 145 - public function getUserVote() { 146 - return $this->vote; 147 - } 148 - 149 95 public function setComments($comments) { 150 96 $this->comments = $comments; 151 97 return $this; ··· 227 173 228 174 public function shouldUseMarkupCache($field) { 229 175 return (bool)$this->getID(); 230 - } 231 - 232 - // votable interface 233 - public function getUserVoteEdgeType() { 234 - return PonderVotingUserHasQuestionEdgeType::EDGECONST; 235 - } 236 - 237 - public function getVotablePHID() { 238 - return $this->getPHID(); 239 176 } 240 177 241 178 public function save() {