@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

Generate expected Ponder schemata

Summary:
Ref T1191.

- Removes ponder comment table. This was migrated a very long time ago.

Test Plan:
- Grepped for removed table.
- Saw ~100 fewer issues in web UI.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T1191

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

+77 -135
+1
resources/sql/autopatches/20140926.schema.07.droppondcom.sql
··· 1 + DROP TABLE {$NAMESPACE}_ponder.ponder_comment;
+2 -7
src/__phutil_library_map__.php
··· 2688 2688 'PonderAnswerTransaction' => 'applications/ponder/storage/PonderAnswerTransaction.php', 2689 2689 'PonderAnswerTransactionComment' => 'applications/ponder/storage/PonderAnswerTransactionComment.php', 2690 2690 'PonderAnswerTransactionQuery' => 'applications/ponder/query/PonderAnswerTransactionQuery.php', 2691 - 'PonderComment' => 'applications/ponder/storage/PonderComment.php', 2692 - 'PonderCommentQuery' => 'applications/ponder/query/PonderCommentQuery.php', 2693 2691 'PonderConstants' => 'applications/ponder/constants/PonderConstants.php', 2694 2692 'PonderController' => 'applications/ponder/controller/PonderController.php', 2695 2693 'PonderDAO' => 'applications/ponder/storage/PonderDAO.php', ··· 2712 2710 'PonderQuestionTransactionQuery' => 'applications/ponder/query/PonderQuestionTransactionQuery.php', 2713 2711 'PonderQuestionViewController' => 'applications/ponder/controller/PonderQuestionViewController.php', 2714 2712 'PonderRemarkupRule' => 'applications/ponder/remarkup/PonderRemarkupRule.php', 2713 + 'PonderSchemaSpec' => 'applications/ponder/storage/PonderSchemaSpec.php', 2715 2714 'PonderSearchIndexer' => 'applications/ponder/search/PonderSearchIndexer.php', 2716 2715 'PonderTransactionFeedStory' => 'applications/ponder/feed/PonderTransactionFeedStory.php', 2717 2716 'PonderVotableInterface' => 'applications/ponder/storage/PonderVotableInterface.php', ··· 5759 5758 'PonderAnswerTransaction' => 'PhabricatorApplicationTransaction', 5760 5759 'PonderAnswerTransactionComment' => 'PhabricatorApplicationTransactionComment', 5761 5760 'PonderAnswerTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 5762 - 'PonderComment' => array( 5763 - 'PonderDAO', 5764 - 'PhabricatorMarkupInterface', 5765 - ), 5766 - 'PonderCommentQuery' => 'PhabricatorQuery', 5767 5761 'PonderController' => 'PhabricatorController', 5768 5762 'PonderDAO' => 'PhabricatorLiskDAO', 5769 5763 'PonderEditor' => 'PhabricatorApplicationTransactionEditor', ··· 5795 5789 'PonderQuestionTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 5796 5790 'PonderQuestionViewController' => 'PonderController', 5797 5791 'PonderRemarkupRule' => 'PhabricatorObjectRemarkupRule', 5792 + 'PonderSchemaSpec' => 'PhabricatorConfigSchemaSpec', 5798 5793 'PonderSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 5799 5794 'PonderTransactionFeedStory' => 'PhabricatorApplicationTransactionFeedStory', 5800 5795 'PonderVotableView' => 'AphrontView',
+4 -2
src/applications/config/controller/PhabricatorConfigDatabaseIssueController.php
··· 144 144 new PhutilNumber($counts[PhabricatorConfigStorageSchema::STATUS_NOTE])); 145 145 } 146 146 147 + $title = pht('Database Issues'); 148 + 147 149 $table_box = id(new PHUIObjectBoxView()) 148 - ->setHeaderText(pht('Database Issues')) 150 + ->setHeaderText($title) 149 151 ->setFormErrors($errors) 150 152 ->appendChild($table); 151 153 ··· 160 162 return $this->buildApplicationPage( 161 163 $nav, 162 164 array( 163 - 'title' => 'all', 165 + 'title' => $title, 164 166 )); 165 167 } 166 168
+3
src/applications/config/schema/PhabricatorConfigSchemaSpec.php
··· 233 233 case 'uint32': 234 234 $column_type = 'int(10) unsigned'; 235 235 break; 236 + case 'sint32': 237 + $column_type = 'int(10)'; 238 + break; 236 239 case 'id64': 237 240 case 'uint64': 238 241 $column_type = 'bigint(20) unsigned';
-65
src/applications/ponder/query/PonderCommentQuery.php
··· 1 - <?php 2 - 3 - final class PonderCommentQuery extends PhabricatorQuery { 4 - 5 - private $ids; 6 - private $authorPHID; 7 - private $targetPHIDs; 8 - 9 - public function withIDs($qids) { 10 - $this->ids = $qids; 11 - return $this; 12 - } 13 - 14 - public function withTargetPHIDs($phids) { 15 - $this->targetPHIDs = $phids; 16 - return $this; 17 - } 18 - 19 - public function withAuthorPHID($phid) { 20 - $this->authorPHID = $phid; 21 - return $this; 22 - } 23 - 24 - private function buildWhereClause($conn_r) { 25 - $where = array(); 26 - if ($this->ids) { 27 - $where[] = qsprintf($conn_r, 'id in (%Ls)', $this->ids); 28 - } 29 - if ($this->authorPHID) { 30 - $where[] = qsprintf($conn_r, 'authorPHID = %s', $this->authorPHID); 31 - } 32 - if ($this->targetPHIDs) { 33 - $where[] = qsprintf($conn_r, 'targetPHID in (%Ls)', $this->targetPHIDs); 34 - } 35 - 36 - return $this->formatWhereClause($where); 37 - } 38 - 39 - private function buildOrderByClause($conn_r) { 40 - return 'ORDER BY id'; 41 - } 42 - 43 - public function execute() { 44 - $comment = new PonderComment(); 45 - $conn_r = $comment->establishConnection('r'); 46 - 47 - $select = qsprintf( 48 - $conn_r, 49 - 'SELECT r.* FROM %T r', 50 - $comment->getTableName()); 51 - 52 - $where = $this->buildWhereClause($conn_r); 53 - $order_by = $this->buildOrderByClause($conn_r); 54 - 55 - return $comment->loadAllFromArray( 56 - queryfx_all( 57 - $conn_r, 58 - '%Q %Q %Q', 59 - $select, 60 - $where, 61 - $order_by)); 62 - } 63 - 64 - 65 - }
+22
src/applications/ponder/storage/PonderAnswer.php
··· 67 67 public function getConfiguration() { 68 68 return array( 69 69 self::CONFIG_AUX_PHID => true, 70 + self::CONFIG_COLUMN_SCHEMA => array( 71 + 'voteCount' => 'sint32', 72 + 'content' => 'text', 73 + 'contentSource' => 'text', 74 + ), 75 + self::CONFIG_KEY_SCHEMA => array( 76 + 'key_phid' => null, 77 + 'phid' => array( 78 + 'columns' => array('phid'), 79 + 'unique' => true, 80 + ), 81 + 'key_oneanswerperquestion' => array( 82 + 'columns' => array('questionID', 'authorPHID'), 83 + 'unique' => true, 84 + ), 85 + 'questionID' => array( 86 + 'columns' => array('questionID'), 87 + ), 88 + 'authorPHID' => array( 89 + 'columns' => array('authorPHID'), 90 + ), 91 + ), 70 92 ) + parent::getConfiguration(); 71 93 } 72 94
-40
src/applications/ponder/storage/PonderComment.php
··· 1 - <?php 2 - 3 - final class PonderComment extends PonderDAO 4 - implements PhabricatorMarkupInterface { 5 - 6 - const MARKUP_FIELD_CONTENT = 'markup:content'; 7 - 8 - protected $targetPHID; 9 - protected $authorPHID; 10 - protected $content; 11 - 12 - public function getMarkupFieldKey($field) { 13 - $hash = PhabricatorHash::digest($this->getMarkupText($field)); 14 - $id = $this->getID(); 15 - return "ponder:c{$id}:{$field}:{$hash}"; 16 - } 17 - 18 - public function getMarkupText($field) { 19 - return $this->getContent(); 20 - } 21 - 22 - public function newMarkupEngine($field) { 23 - return PhabricatorMarkupEngine::getEngine(); 24 - } 25 - 26 - public function didMarkupText( 27 - $field, 28 - $output, 29 - PhutilMarkupEngine $engine) { 30 - return $output; 31 - } 32 - 33 - public function shouldUseMarkupCache($field) { 34 - return (bool)$this->getID(); 35 - } 36 - 37 - public function getMarkupField() { 38 - return self::MARKUP_FIELD_CONTENT; 39 - } 40 - }
+26 -21
src/applications/ponder/storage/PonderQuestion.php
··· 33 33 public function getConfiguration() { 34 34 return array( 35 35 self::CONFIG_AUX_PHID => true, 36 + self::CONFIG_COLUMN_SCHEMA => array( 37 + 'title' => 'text255', 38 + 'voteCount' => 'sint32', 39 + 'status' => 'uint32', 40 + 'content' => 'text', 41 + 'contentSource' => 'text', 42 + 'heat' => 'double', 43 + 'answerCount' => 'uint32', 44 + 'mailKey' => 'bytes20', 45 + ), 46 + self::CONFIG_KEY_SCHEMA => array( 47 + 'key_phid' => null, 48 + 'phid' => array( 49 + 'columns' => array('phid'), 50 + 'unique' => true, 51 + ), 52 + 'authorPHID' => array( 53 + 'columns' => array('authorPHID'), 54 + ), 55 + 'heat' => array( 56 + 'columns' => array('heat'), 57 + ), 58 + 'status' => array( 59 + 'columns' => array('status'), 60 + ), 61 + ), 36 62 ) + parent::getConfiguration(); 37 63 } 38 64 ··· 47 73 48 74 public function getContentSource() { 49 75 return PhabricatorContentSource::newFromSerialized($this->contentSource); 50 - } 51 - 52 - public function attachRelated() { 53 - $this->answers = $this->loadRelatives(new PonderAnswer(), 'questionID'); 54 - $qa_phids = mpull($this->answers, 'getPHID') + array($this->getPHID()); 55 - 56 - if ($qa_phids) { 57 - $comments = id(new PonderCommentQuery()) 58 - ->withTargetPHIDs($qa_phids) 59 - ->execute(); 60 - 61 - $comments = mgroup($comments, 'getTargetPHID'); 62 - } else { 63 - $comments = array(); 64 - } 65 - 66 - $this->setComments(idx($comments, $this->getPHID(), array())); 67 - foreach ($this->answers as $answer) { 68 - $answer->attachQuestion($this); 69 - $answer->setComments(idx($comments, $answer->getPHID(), array())); 70 - } 71 76 } 72 77 73 78 public function attachVotes($user_phid) {
+19
src/applications/ponder/storage/PonderSchemaSpec.php
··· 1 + <?php 2 + 3 + final class PonderSchemaSpec extends PhabricatorConfigSchemaSpec { 4 + 5 + public function buildSchemata() { 6 + $this->buildLiskSchemata('PonderDAO'); 7 + 8 + $this->buildEdgeSchemata(new PonderQuestion()); 9 + 10 + $this->buildTransactionSchema( 11 + new PonderQuestionTransaction(), 12 + new PonderQuestionTransactionComment()); 13 + 14 + $this->buildTransactionSchema( 15 + new PonderAnswerTransaction(), 16 + new PonderAnswerTransactionComment()); 17 + } 18 + 19 + }