r105243 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105242‎ | r105243 | r105244 >
Date:23:18, 5 December 2011
Author:rsterbin
Status:ok
Tags:
Comment:
No need for newest and default to be separate
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiViewFeedbackArticleFeedbackv5.php
@@ -8,7 +8,7 @@
99 */
1010
1111 /**
12 - * This class pulls the individual ratings/comments for the feedback page.
 12+ * This class pulls the individual ratings/comments for the feedback page.
1313 *
1414 * @package ArticleFeedback
1515 * @subpackage Api
@@ -31,7 +31,7 @@
3232 $result = $this->getResult();
3333 $pageId = $params['pageid'];
3434 $length = 0;
35 - $count = $this->fetchFeedbackCount(
 35+ $count = $this->fetchFeedbackCount(
3636 $params['pageid'], $params['filter'] );
3737 $feedback = $this->fetchFeedback(
3838 $params['pageid'],
@@ -91,7 +91,7 @@
9292 );
9393 }
9494
95 - public function fetchFeedback( $pageId,
 95+ public function fetchFeedback( $pageId,
9696 $filter = 'visible', $order = 'newest', $limit = 25, $offset = 0 ) {
9797 $dbr = wfGetDB( DB_SLAVE );
9898 $ids = array();
@@ -100,10 +100,9 @@
101101 $where = $this->getFilterCriteria( $filter );
102102 $order;
103103
 104+ # Newest first is the only option right now.
104105 switch($order) {
105106 case 'newest':
106 - $order = 'af_id DESC';
107 - break;
108107 default:
109108 $order = 'af_id DESC';
110109 break;
@@ -112,16 +111,16 @@
113112 $where['af_page_id'] = $pageId;
114113
115114 /* I'd really love to do this in one big query, but MySQL
116 - doesn't support LIMIT inside IN() subselects, and since
 115+ doesn't support LIMIT inside IN() subselects, and since
117116 we don't know the number of answers for each feedback
118117 record until we fetch them, this is the only way to make
119118 sure we get all answers for the exact IDs we want. */
120119 $id_query = $dbr->select(
121120 'aft_article_feedback', 'af_id', $where, __METHOD__,
122 - array(
123 - 'LIMIT' => $limit,
 121+ array(
 122+ 'LIMIT' => $limit,
124123 'OFFSET' => $offset,
125 - 'ORDER BY' => $order
 124+ 'ORDER BY' => $order
126125 )
127126 );
128127 foreach($id_query as $id) {
@@ -129,11 +128,11 @@
130129 }
131130
132131 $rows = $dbr->select(
133 - array( 'aft_article_feedback', 'aft_article_answer',
 132+ array( 'aft_article_feedback', 'aft_article_answer',
134133 'aft_article_field', 'aft_article_field_option'
135134 ),
136135 array( 'af_id', 'af_bucket_id', 'afi_name', 'afo_name',
137 - 'aa_response_text', 'aa_response_boolean',
 136+ 'aa_response_text', 'aa_response_boolean',
138137 'aa_response_rating', 'aa_response_option_id',
139138 'afi_data_type', 'af_created', 'af_user_text',
140139 'af_hide_count', 'af_abuse_count'
@@ -149,7 +148,7 @@
150149 'LEFT JOIN', 'af_id = aa_feedback_id'
151150 ),
152151 'aft_article_field_option' => array(
153 - 'LEFT JOIN',
 152+ 'LEFT JOIN',
154153 'aa_response_option_id = afo_option_id'
155154 )
156155 )
@@ -208,26 +207,26 @@
209208 return $rv;
210209 }
211210
212 - private function renderBucket1( $record ) {
 211+ private function renderBucket1( $record ) {
213212 $name = $record[0]->af_user_text;
214213 if( $record['found']->aa_response_boolean ) {
215 - $found = wfMsg(
 214+ $found = wfMsg(
216215 'articlefeedbackv5-form1-header-found',
217216 $name
218217 );
219218 } else {
220 - $found = wfMsg(
 219+ $found = wfMsg(
221220 'articlefeedbackv5-form1-header-not-found',
222221 $name
223222 );
224223
225224 }
226 - return "$found
 225+ return "$found
227226 <blockquote>".$record['comment']->aa_response_text
228227 .'</blockquote>';
229228 }
230229
231 - private function renderBucket2( $record ) {
 230+ private function renderBucket2( $record ) {
232231 $name = $record[0]->af_user_text;
233232 $type = $record['tag']->afo_name;
234233 return wfMsg( 'articlefeedbackv5-form2-header', $name, $type )
@@ -235,7 +234,7 @@
236235 .'</blockquote>';
237236 }
238237
239 - private function renderBucket3( $record ) {
 238+ private function renderBucket3( $record ) {
240239 $name = $record[0]->af_user_text;
241240 $rating = $record['rating']->aa_response_rating;
242241 return wfMsg( 'articlefeedbackv5-form3-header', $name, $rating )
@@ -243,11 +242,11 @@
244243 .'</blockquote>';
245244 }
246245
247 - private function renderBucket4( $record ) {
 246+ private function renderBucket4( $record ) {
248247 return wfMsg( 'articlefeedbackv5-form4-header' );
249248 }
250249
251 - private function renderBucket5( $record ) {
 250+ private function renderBucket5( $record ) {
252251 $name = $record[0]->af_user_text;
253252 $rv = wfMsg( 'articlefeedbackv5-form5-header', $name );
254253 $rv .= '<ul>';
@@ -261,16 +260,16 @@
262261 return $rv;
263262 }
264263
265 - private function renderBucket0( $record ) {
 264+ private function renderBucket0( $record ) {
266265 # Future-proof this for when the bucket ID changes to 0.
267266 return $this->renderBucket6( $record );
268267 }
269268
270 - private function renderNoBucket( $record ) {
 269+ private function renderNoBucket( $record ) {
271270 return wfMsg( 'articlefeedbackv5-form-invalid' );
272271 }
273272
274 - private function renderBucket6( $record ) {
 273+ private function renderBucket6( $record ) {
275274 return wfMsg( 'articlefeedbackv5-form-not-shown' );
276275 }
277276
@@ -289,13 +288,13 @@
290289 'sort' => array(
291290 ApiBase::PARAM_REQUIRED => false,
292291 ApiBase::PARAM_ISMULTI => false,
293 - ApiBase::PARAM_TYPE => array(
 292+ ApiBase::PARAM_TYPE => array(
294293 'oldest', 'newest', 'etc' )
295294 ),
296295 'filter' => array(
297296 ApiBase::PARAM_REQUIRED => false,
298297 ApiBase::PARAM_ISMULTI => false,
299 - ApiBase::PARAM_TYPE => array(
 298+ ApiBase::PARAM_TYPE => array(
300299 'all', 'hidden', 'visible' )
301300 ),
302301 'limit' => array(

Status & tagging log