https://www.mediawiki.org/wiki/Special:Code/MediaWiki/105449

Revision: 105449
Author:   gregchiasson
Date:     2011-12-07 19:04:34 +0000 (Wed, 07 Dec 2011)
Log Message:
-----------
AFTv5 - Re-enable isFeedbackEnabled check, move getAnonToken to the right 
place, and pass __METHOD__ into select in a couple of places where it was 
missing.

Modified Paths:
--------------
    trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php
    trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php

Modified: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php
===================================================================
--- trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php     
2011-12-07 18:37:05 UTC (rev 105448)
+++ trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5.php     
2011-12-07 19:04:34 UTC (rev 105449)
@@ -32,12 +32,12 @@
                $params = $this->extractRequestParams();
 
                // Anon token check
-               $token = ApiArticleFeedbackv5Utils::getAnonToken( $params );
+               $token = $this->getAnonToken( $params );
 
                // Is feedback enabled on this page check?
-#              if ( !ApiArticleFeedbackv5Utils::isFeedbackEnabled( $params ) ) 
{
-#                      $this->dieUsage( 'ArticleFeedback is not enabled on 
this page', 'invalidpage' );
-#              }
+               if ( !ApiArticleFeedbackv5Utils::isFeedbackEnabled( $params ) ) 
{
+                       $this->dieUsage( 'ArticleFeedback is not enabled on 
this page', 'invalidpage' );
+               }
 
                $feedbackId   = $this->newFeedback( $params );
                $dbr          = wfGetDB( DB_SLAVE );
@@ -313,7 +313,7 @@
                $revId     = $params['revid'];
                $bucket    = $params['bucket'];
                $link      = $params['link'];
-               $token     = ApiArticleFeedbackv5Utils::getAnonToken( $params );
+               $token     = $this->getAnonToken( $params );
                $timestamp = $dbw->timestamp();
                $ip        = wfGetIP();
 
@@ -379,6 +379,28 @@
        }
 
        /**
+       * Gets the anonymous token from the params
+       *
+       * @param  $params array the params
+       * @return string the token, or null if the user is not anonymous
+       */
+       public function getAnonToken( $params ) {
+               global $wgUser;
+               $token = null;
+               if ( $wgUser->isAnon() ) {
+                       if ( !isset( $params['anontoken'] ) ) {
+                               $this->dieUsageMsg( array( 'missingparam', 
'anontoken' ) );
+                       } elseif ( strlen( $params['anontoken'] ) != 32 ) {
+                               $this->dieUsage( 'The anontoken is not 32 
characters', 'invalidtoken' );
+                       }
+                       $token = $params['anontoken'];
+               } else {
+                       $token = '';
+               }
+               return $token;
+       }
+
+       /**
         * Gets the allowed parameters
         *
         * @return array the params info, indexed by allowed key

Modified: trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php
===================================================================
--- trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php        
2011-12-07 18:37:05 UTC (rev 105448)
+++ trunk/extensions/ArticleFeedbackv5/api/ApiArticleFeedbackv5Utils.php        
2011-12-07 19:04:34 UTC (rev 105449)
@@ -20,31 +20,7 @@
  * @subpackage Api
  */
 class ApiArticleFeedbackv5Utils {
-
        /**
-        * Gets the anonymous token from the params
-        *
-        * @param  $params array the params
-        * @return string the token, or null if the user is not anonymous
-        */
-       public static function getAnonToken( $params ) {
-               global $wgUser;
-               $token = null;
-               if ( $wgUser->isAnon() ) {
-# TODO: error handling
-                       if ( !isset( $params['anontoken'] ) ) {
-#                                $this->dieUsageMsg( array( 'missingparam', 
'anontoken' ) );
-                       } elseif ( strlen( $params['anontoken'] ) != 32 ) {
-#                                $this->dieUsage( 'The anontoken is not 32 
characters', 'invalidtoken' );
-                       }
-                       $token = $params['anontoken'];
-               } else {
-                       $token = '';
-               }
-               return $token;
-       }
-
-       /**
         * Returns whether feedback is enabled for this page
         *
         * @param  $params array the params
@@ -100,7 +76,9 @@
                $dbr = wfGetDB( DB_SLAVE );
                $rv  = $dbr->select(
                        'aft_article_field',
-                       array( 'afi_name', 'afi_id', 'afi_data_type', 
'afi_bucket_id' )
+                       array( 'afi_name', 'afi_id', 'afi_data_type', 
'afi_bucket_id' ),
+                       null, 
+                       __METHOD__
                );
                return $rv;
        }
@@ -122,7 +100,9 @@
                $dbr  = wfGetDB( DB_SLAVE );
                $rows = $dbr->select(
                        'aft_article_field_option',
-                       array( 'afo_option_id', 'afo_field_id', 'afo_name' )
+                       array( 'afo_option_id', 'afo_field_id', 'afo_name' ),
+                       null, 
+                       __METHOD__
                );
                $rv = array();
                foreach ( $rows as $row ) {
@@ -130,6 +110,5 @@
                }
                return $rv;
        }
-
 }
 


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to