r105246 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105245‎ | r105246 | r105247 >
Date:23:31, 5 December 2011
Author:rsterbin
Status:ok
Tags:
Comment:
Tweaks and bug fixes for submit API call, as per Roan's review:
- Dropped comment about escaping text in the validation method, since we're
not going to do that
- Renamed getFeedbackId() to newFeedback()
- Dropped unnecessary ISMULTI => false and REQUIRED => false definitions
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php
@@ -39,7 +39,7 @@
4040 # $this->dieUsage( 'ArticleFeedback is not enabled on this page', 'invalidpage' );
4141 # }
4242
43 - $feedbackId = $this->getFeedbackId( $params );
 43+ $feedbackId = $this->newFeedback( $params );
4444 $dbr = wfGetDB( DB_SLAVE );
4545 $pageId = $params['pageid'];
4646 $bucket = $params['bucket'];
@@ -82,7 +82,7 @@
8383 $this->updateRollupTables( $pageId, $revisionId );
8484
8585 if( $params['email'] ) {
86 - $this->captureEmail ( $params['email'], json_encode(
 86+ $this->captureEmail ( $params['email'], json_encode(
8787 $email_data
8888 ) );
8989 }
@@ -139,7 +139,7 @@
140140 # rating: int between 1 and 5 (inclusive)
141141 # boolean: 1 or 0
142142 # option_id: option exists
143 - # text: none (maybe xss encode)
 143+ # text: none
144144 switch ( $type ) {
145145 case 'rating':
146146 if ( preg_match( '/^(1|2|3|4|5)$/', $value ) ) {
@@ -302,12 +302,12 @@
303303 }
304304
305305 /**
306 - * Gets the feedback id
 306+ * Creates a new feedback row and returns the id
307307 *
308308 * @param $params array the parameters
309309 * @return int the feedback id
310310 */
311 - public function getFeedbackId($params) {
 311+ public function newFeedback( $params ) {
312312 global $wgUser;
313313 $dbw = wfGetDB( DB_MASTER );
314314 $revId = $params['revid'];
@@ -323,7 +323,7 @@
324324
325325 # Fetch this if it wasn't passed in
326326 if ( !$revId ) {
327 - $revId = ApiArticleFeedbackv5Utils::getRevisionId($params['pageid']);
 327+ $revId = ApiArticleFeedbackv5Utils::getRevisionId( $params['pageid'] );
328328 }
329329
330330 $dbw->insert( 'aft_article_feedback', array(
@@ -372,7 +372,7 @@
373373 * @param $bucket int the bucket id
374374 * @return int the cta id
375375 */
376 - public function getCTAId($answers, $bucket) {
 376+ public function getCTAId( $answers, $bucket ) {
377377 return 1; # Hard-code this for now.
378378 }
379379
@@ -386,30 +386,24 @@
387387 'pageid' => array(
388388 ApiBase::PARAM_TYPE => 'integer',
389389 ApiBase::PARAM_REQUIRED => true,
390 - ApiBase::PARAM_ISMULTI => false,
391390 ),
392391 'revid' => array(
393392 ApiBase::PARAM_TYPE => 'integer',
394393 ApiBase::PARAM_REQUIRED => true,
395 - ApiBase::PARAM_ISMULTI => false,
396394 ),
397395 'anontoken' => null,
398396 'bucket' => array(
399397 ApiBase::PARAM_TYPE => 'integer',
400398 ApiBase::PARAM_REQUIRED => true,
401 - ApiBase::PARAM_ISMULTI => false,
402399 ApiBase::PARAM_MIN => 0
403400 ),
404401 'link' => array(
405402 ApiBase::PARAM_TYPE => 'integer',
406403 ApiBase::PARAM_REQUIRED => true,
407 - ApiBase::PARAM_ISMULTI => false,
408404 ApiBase::PARAM_MIN => 0
409405 ),
410406 'email' => array(
411407 ApiBase::PARAM_TYPE => 'string',
412 - ApiBase::PARAM_REQUIRED => false,
413 - ApiBase::PARAM_ISMULTI => false,
414408 )
415409 );
416410

Status & tagging log