From 42b5c265c0b9c8323f659f3082152c28ed1ad2e6 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Fri, 1 Oct 2010 20:12:50 +0000 Subject: [PATCH] * (bug 25248) API: paraminfo errors with certain modules Added a needsToken() function, rather than calling getTokenSalt, which can throw silly errors due to dependencies on parameters --- RELEASE-NOTES | 1 + includes/api/ApiBase.php | 10 +++++++++- includes/api/ApiBlock.php | 4 ++++ includes/api/ApiDelete.php | 4 ++++ includes/api/ApiEditPage.php | 4 ++++ includes/api/ApiEmailUser.php | 4 ++++ includes/api/ApiImport.php | 4 ++++ includes/api/ApiMove.php | 4 ++++ includes/api/ApiPatrol.php | 4 ++++ includes/api/ApiProtect.php | 6 +++++- includes/api/ApiRollback.php | 4 ++++ includes/api/ApiUnblock.php | 4 ++++ includes/api/ApiUndelete.php | 4 ++++ includes/api/ApiUpload.php | 4 ++++ includes/api/ApiUserrights.php | 4 ++++ 15 files changed, 63 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2d4e4dce7d..fabb606393 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 78d44bc4e6..c025c4d682 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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' ); } diff --git a/includes/api/ApiBlock.php b/includes/api/ApiBlock.php index ecfc45fa9c..3055007d7a 100644 --- a/includes/api/ApiBlock.php +++ b/includes/api/ApiBlock.php @@ -183,6 +183,10 @@ class ApiBlock extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return ''; } diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php index 0c9acb017c..f4e2ec249e 100644 --- a/includes/api/ApiDelete.php +++ b/includes/api/ApiDelete.php @@ -246,6 +246,10 @@ class ApiDelete extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return ''; } diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 8742f8b4d1..83d9c16ab6 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -481,6 +481,10 @@ class ApiEditPage extends ApiBase { ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return ''; } diff --git a/includes/api/ApiEmailUser.php b/includes/api/ApiEmailUser.php index 886e3e170f..38503b13c5 100644 --- a/includes/api/ApiEmailUser.php +++ b/includes/api/ApiEmailUser.php @@ -119,6 +119,10 @@ class ApiEmailUser extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return ''; } diff --git a/includes/api/ApiImport.php b/includes/api/ApiImport.php index 8045cea09f..5567db52c2 100644 --- a/includes/api/ApiImport.php +++ b/includes/api/ApiImport.php @@ -154,6 +154,10 @@ class ApiImport extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return ''; } diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index ed80831cfe..a393104b16 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -233,6 +233,10 @@ class ApiMove extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return ''; } diff --git a/includes/api/ApiPatrol.php b/includes/api/ApiPatrol.php index 77b54cead1..d424dd0b20 100644 --- a/includes/api/ApiPatrol.php +++ b/includes/api/ApiPatrol.php @@ -90,6 +90,10 @@ class ApiPatrol extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return ''; } diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index 7617ae0b84..6a1658c8d6 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -207,8 +207,12 @@ class ApiProtect extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { - return null; + return ''; } protected function getExamples() { diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php index 72604b963b..f0360d90f5 100644 --- a/includes/api/ApiRollback.php +++ b/includes/api/ApiRollback.php @@ -128,6 +128,10 @@ class ApiRollback extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return array( $this->getTitle()->getPrefixedText(), $this->getUser() ); } diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php index b53b5da9d6..45d951e66c 100644 --- a/includes/api/ApiUnblock.php +++ b/includes/api/ApiUnblock.php @@ -129,6 +129,10 @@ class ApiUnblock extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return ''; } diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index 98c06d0722..7205d05ded 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -143,6 +143,10 @@ class ApiUndelete extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return ''; } diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php index 1cc903439a..13268a7292 100644 --- a/includes/api/ApiUpload.php +++ b/includes/api/ApiUpload.php @@ -459,6 +459,10 @@ class ApiUpload extends ApiBase { ) ); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return ''; } diff --git a/includes/api/ApiUserrights.php b/includes/api/ApiUserrights.php index 2649f9dd98..b3b22cafb4 100644 --- a/includes/api/ApiUserrights.php +++ b/includes/api/ApiUserrights.php @@ -125,6 +125,10 @@ class ApiUserrights extends ApiBase { return parent::getPossibleErrors(); } + public function needsToken() { + return true; + } + public function getTokenSalt() { return $this->getUser()->getName(); } -- 2.20.1