* (bug 25248) API: paraminfo errors with certain modules
authorSam Reed <reedy@users.mediawiki.org>
Fri, 1 Oct 2010 20:12:50 +0000 (20:12 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Fri, 1 Oct 2010 20:12:50 +0000 (20:12 +0000)
Added a needsToken() function, rather than calling getTokenSalt, which can throw silly errors due to dependencies on parameters

15 files changed:
RELEASE-NOTES
includes/api/ApiBase.php
includes/api/ApiBlock.php
includes/api/ApiDelete.php
includes/api/ApiEditPage.php
includes/api/ApiEmailUser.php
includes/api/ApiImport.php
includes/api/ApiMove.php
includes/api/ApiPatrol.php
includes/api/ApiProtect.php
includes/api/ApiRollback.php
includes/api/ApiUnblock.php
includes/api/ApiUndelete.php
includes/api/ApiUpload.php
includes/api/ApiUserrights.php

index 2d4e4dc..fabb606 100644 (file)
@@ -421,6 +421,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   $wgAllowAsyncCopyUploads to be true.
 * sinumberingroup correctly gives size of 'user' group, and omits size of
   implicit groups rather than showing 0.
+* (bug 25248) API: paraminfo errors with certain modules
 
 === Languages updated in 1.17 ===
 
index 78d44bc..c025c4d 100644 (file)
@@ -1093,6 +1093,14 @@ abstract class ApiBase {
                return false;
        }
 
+       /**
+        * Returns whether this module requires a Token to execute
+        * @returns bool
+        */
+       public function needsToken() {
+               return false;
+       }
+
        /**
         * Returns the token salt if there is one, '' if the module doesn't require a salt, else false if the module doesn't need a token
         * @returns bool
@@ -1155,7 +1163,7 @@ abstract class ApiBase {
                        $ret[] = array( 'writedisabled' );
                }
 
-               if ( $this->getTokenSalt() !== false ) {
+               if ( $this->needsToken() ) {
                        $ret[] = array( 'missingparam', 'token' );
                        $ret[] = array( 'sessionfailure' );
                }
index ecfc45f..3055007 100644 (file)
@@ -183,6 +183,10 @@ class ApiBlock extends ApiBase {
                ) );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return '';
        }
index 0c9acb0..f4e2ec2 100644 (file)
@@ -246,6 +246,10 @@ class ApiDelete extends ApiBase {
                ) );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return '';
        }
index 8742f8b..83d9c16 100644 (file)
@@ -481,6 +481,10 @@ class ApiEditPage extends ApiBase {
                );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return '';
        }
index 886e3e1..38503b1 100644 (file)
@@ -119,6 +119,10 @@ class ApiEmailUser extends ApiBase {
                ) );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return '';
        }
index 8045cea..5567db5 100644 (file)
@@ -154,6 +154,10 @@ class ApiImport extends ApiBase {
                ) );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return '';
        }
index ed80831..a393104 100644 (file)
@@ -233,6 +233,10 @@ class ApiMove extends ApiBase {
                ) );
        }
 
+               public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return '';
        }
index 77b54ce..d424dd0 100644 (file)
@@ -90,6 +90,10 @@ class ApiPatrol extends ApiBase {
                ) );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return '';
        }
index 7617ae0..6a1658c 100644 (file)
@@ -207,8 +207,12 @@ class ApiProtect extends ApiBase {
                ) );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
-               return null;
+               return '';
        }
 
        protected function getExamples() {
index 72604b9..f0360d9 100644 (file)
@@ -128,6 +128,10 @@ class ApiRollback extends ApiBase {
                ) );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return array( $this->getTitle()->getPrefixedText(), $this->getUser() );
        }
index b53b5da..45d951e 100644 (file)
@@ -129,6 +129,10 @@ class ApiUnblock extends ApiBase {
                ) );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return '';
        }
index 98c06d0..7205d05 100644 (file)
@@ -143,6 +143,10 @@ class ApiUndelete extends ApiBase {
                ) );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return '';
        }
index 1cc9034..13268a7 100644 (file)
@@ -459,6 +459,10 @@ class ApiUpload extends ApiBase {
                ) );
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return '';
        }
index 2649f9d..b3b22ca 100644 (file)
@@ -125,6 +125,10 @@ class ApiUserrights extends ApiBase {
                return parent::getPossibleErrors();
        }
 
+       public function needsToken() {
+               return true;
+       }
+
        public function getTokenSalt() {
                return $this->getUser()->getName();
        }