* (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
This commit is contained in:
Sam Reed 2010-10-01 20:12:50 +00:00
parent c48bbaec3c
commit 42b5c265c0
15 changed files with 63 additions and 2 deletions

View 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 ===

View 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' );
}

View file

@ -183,6 +183,10 @@ class ApiBlock extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return '';
}

View file

@ -246,6 +246,10 @@ class ApiDelete extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return '';
}

View file

@ -481,6 +481,10 @@ class ApiEditPage extends ApiBase {
);
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return '';
}

View file

@ -119,6 +119,10 @@ class ApiEmailUser extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return '';
}

View file

@ -154,6 +154,10 @@ class ApiImport extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return '';
}

View file

@ -233,6 +233,10 @@ class ApiMove extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return '';
}

View file

@ -90,6 +90,10 @@ class ApiPatrol extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return '';
}

View file

@ -207,8 +207,12 @@ class ApiProtect extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return null;
return '';
}
protected function getExamples() {

View file

@ -128,6 +128,10 @@ class ApiRollback extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return array( $this->getTitle()->getPrefixedText(), $this->getUser() );
}

View file

@ -129,6 +129,10 @@ class ApiUnblock extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return '';
}

View file

@ -143,6 +143,10 @@ class ApiUndelete extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return '';
}

View file

@ -459,6 +459,10 @@ class ApiUpload extends ApiBase {
) );
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return '';
}

View file

@ -125,6 +125,10 @@ class ApiUserrights extends ApiBase {
return parent::getPossibleErrors();
}
public function needsToken() {
return true;
}
public function getTokenSalt() {
return $this->getUser()->getName();
}