r105242 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105241‎ | r105242 | r105243 >
Date:23:13, 5 December 2011
Author:rsterbin
Status:ok
Tags:
Comment:
Tweaks and bug fixes for view-ratings API call, as per Roan's review:
- Dropped unused setIndexedTagname_internal() call
- Removed fetchRevisionRollup() and consolidated fetchPageRollup() and
fetchRollup()
- Dropped unused userrating, subaction, anontoken, and revid parameters
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewRatingsArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewRatingsArticleFeedbackv5.php
@@ -36,7 +36,7 @@
3737 $result_path = array( 'query', $this->getModuleName() );
3838 $revisionId = ApiArticleFeedbackv5Utils::getRevisionId( $params['pageid'] );
3939 $pageId = $params['pageid'];
40 - $rollup = $this->fetchPageRollup( $pageId );
 40+ $rollup = $this->fetchRollup( $pageId );
4141
4242 $result->addValue( $result_path, 'pageid', $params['pageid'] );
4343 $result->addValue( $result_path, 'status', 'current' );
@@ -51,32 +51,9 @@
5252 );
5353 }
5454 $result->addValue( $result_path, 'rollup', $info );
55 -
56 - $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'aa' );
5755 }
5856
5957 /**
60 - * Pulls the page rollup row
61 - *
62 - * @param $pageId int the page id
63 - * @return array the rollup row
64 - */
65 - public function fetchPageRollup( $pageId ) {
66 - return $this->fetchRollup( $pageId, 0, 'page' );
67 - }
68 -
69 - /**
70 - * Pulls the revision rollup row
71 - *
72 - * @param $pageId int the page id
73 - * @param $revisionLimit int [optional] go back only to this revision
74 - * @return array the rollup row
75 - */
76 - public function fetchRevisionRollup( $pageId, $revisionLimit = 0 ) {
77 - return $this->fetchRollup( $pageId, $revisionLimit, 'revision' );
78 - }
79 -
80 - /**
8158 * Pulls a rollup row
8259 *
8360 * @param $pageId int the page id
@@ -85,20 +62,12 @@
8663 * @return array the rollup row
8764 */
8865 private function fetchRollup( $pageId, $revisionLimit, $type ) {
89 - $dbr = wfGetDB( DB_SLAVE );
90 - $where = array();
91 -
92 - if ( $type == 'page' ) {
93 - $table = 'article_feedback_ratings_rollup';
94 - $prefix = 'arr';
95 - } else {
96 - $table = 'article_revision_feedback_ratings_rollup';
97 - $prefix = 'afrr';
98 - $where[] = 'afrr_revision_id >= ' . $revisionLimit;
99 - }
 66+ $dbr = wfGetDB( DB_SLAVE );
 67+ $where = array();
 68+ $table = 'article_feedback_ratings_rollup';
 69+ $prefix = 'arr';
10070 $where[$prefix . '_page_id'] = $pageId;
10171 $where[] = $prefix . '_rating_id = afi_id';
102 -
10372 $rows = $dbr->select(
10473 array( 'aft_' . $table, 'aft_article_field' ),
10574 array(
@@ -124,20 +93,7 @@
12594 */
12695 public function getAllowedParams() {
12796 return array(
128 - 'userrating' => 0,
129 - 'anontoken' => null,
130 - 'userid' => null,
131 - 'subaction' => array(
132 - ApiBase::PARAM_REQUIRED => false,
133 - ApiBase::PARAM_ISMULTI => false,
134 - ApiBase::PARAM_TYPE => array( 'showratings', 'newform' ),
135 - ),
136 - 'revid' => array(
137 - ApiBase::PARAM_REQUIRED => false,
138 - ApiBase::PARAM_ISMULTI => false,
139 - ApiBase::PARAM_TYPE => 'integer',
140 - ),
141 - 'pageid' => array(
 97+ 'pageid' => array(
14298 ApiBase::PARAM_REQUIRED => true,
14399 ApiBase::PARAM_ISMULTI => false,
144100 ApiBase::PARAM_TYPE => 'integer',
@@ -152,9 +108,7 @@
153109 */
154110 public function getParamDescription() {
155111 return array(
156 - 'pageid' => 'Page ID to get feedback ratings for',
157 - 'revid' => 'Rev ID to get feedback ratings for',
158 - 'anontoken' => 'Token for anonymous users',
 112+ 'pageid' => 'Page ID to get feedback ratings for',
159113 );
160114 }
161115
@@ -170,19 +124,6 @@
171125 }
172126
173127 /**
174 - * Gets any possible errors
175 - *
176 - * @return array the errors
177 - */
178 - public function getPossibleErrors() {
179 - return array_merge( parent::getPossibleErrors(), array(
180 - array( 'missingparam', 'anontoken' ),
181 - array( 'code' => 'invalidtoken', 'info' => 'The anontoken is not 32 characters' ),
182 - )
183 - );
184 - }
185 -
186 - /**
187128 * Gets an example
188129 *
189130 * @return array the example as the first element in an array

Status & tagging log