version of the title.
* (bug 52538) action=edit will now use empty text instead of the contents
of section 0 when passed prependtext or appendtext with section=new.
+* Support for the 'gettoken' parameter to action=block and action=unblock,
+ deprecated since 1.20, has been removed.
+* (bug 49090) Token-getting functions will fail when using jsonp callbacks.
=== Languages updated in 1.22===
$user = $this->getUser();
$params = $this->extractRequestParams();
- if ( $params['gettoken'] ) {
- $res['blocktoken'] = $user->getEditToken();
- $this->getResult()->addValue( null, $this->getModuleName(), $res );
- return;
- }
-
if ( !$user->isAllowed( 'block' ) ) {
$this->dieUsageMsg( 'cantblock' );
}
ApiBase::PARAM_REQUIRED => true
),
'token' => null,
- 'gettoken' => array(
- ApiBase::PARAM_DFLT => false,
- ApiBase::PARAM_DEPRECATED => true,
- ),
'expiry' => 'never',
'reason' => '',
'anononly' => false,
return array(
'user' => 'Username, IP address or IP range you want to block',
'token' => 'A block token previously obtained through prop=info',
- 'gettoken' => 'If set, a block token will be returned, and no other action will be taken',
'expiry' => 'Relative expiry time, e.g. \'5 months\' or \'2 weeks\'. If set to \'infinite\', \'indefinite\' or \'never\', the block will never expire.',
'reason' => 'Reason for block',
'anononly' => 'Block anonymous users only (i.e. disable anonymous edits for this IP)',
public function getResultProperties() {
return array(
'' => array(
- 'blocktoken' => array(
- ApiBase::PROP_TYPE => 'string',
- ApiBase::PROP_NULLABLE => true
- ),
'user' => array(
ApiBase::PROP_TYPE => 'string',
ApiBase::PROP_NULLABLE => true
*/
class ApiCreateAccount extends ApiBase {
public function execute() {
+ // If we're in JSON callback mode, no tokens can be obtained
+ if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
+ $this->dieUsage( 'Cannot create account when using a callback', 'aborted' );
+ }
// $loginForm->addNewaccountInternal will throw exceptions
// if wiki is read only (already handled by api), user is blocked or does not have rights.
* is reached. The expiry is $this->mLoginThrottle.
*/
public function execute() {
+ // If we're in JSON callback mode, no tokens can be obtained
+ if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
+ $this->getResult()->addValue( null, 'login', array(
+ 'result' => 'Aborted',
+ 'reason' => 'Cannot log in when using a callback',
+ ) );
+ return;
+ }
+
$params = $this->extractRequestParams();
$result = array();
}
$moduleParams = $module->extractRequestParams();
- // Die if token required, but not provided (unless there is a gettoken parameter)
- if ( isset( $moduleParams['gettoken'] ) ) {
- $gettoken = $moduleParams['gettoken'];
- } else {
- $gettoken = false;
- }
-
+ // Die if token required, but not provided
$salt = $module->getTokenSalt();
- if ( $salt !== false && !$gettoken ) {
+ if ( $salt !== false ) {
if ( !isset( $moduleParams['token'] ) ) {
$this->dieUsageMsg( array( 'missingparam', 'token' ) );
} else {
$fld_content = isset( $prop['content'] );
$fld_token = isset( $prop['token'] );
+ // If we're in JSON callback mode, no tokens can be obtained
+ if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
+ $fld_token = false;
+ }
+
$result = $this->getResult();
$pageSet = $this->getPageSet();
$titles = $pageSet->getTitles();
}
private function getTokenTypes() {
+ // If we're in JSON callback mode, no tokens can be obtained
+ if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
+ return array();
+ }
+
static $types = null;
if ( $types ) {
return $types;
$user = $this->getUser();
$params = $this->extractRequestParams();
- if ( $params['gettoken'] ) {
- $res['unblocktoken'] = $user->getEditToken();
- $this->getResult()->addValue( null, $this->getModuleName(), $res );
- return;
- }
-
if ( is_null( $params['id'] ) && is_null( $params['user'] ) ) {
$this->dieUsageMsg( 'unblock-notarget' );
}
),
'user' => null,
'token' => null,
- 'gettoken' => array(
- ApiBase::PARAM_DFLT => false,
- ApiBase::PARAM_DEPRECATED => true,
- ),
'reason' => '',
);
}
'id' => "ID of the block you want to unblock (obtained through list=blocks). Cannot be used together with {$p}user",
'user' => "Username, IP address or IP range you want to unblock. Cannot be used together with {$p}id",
'token' => "An unblock token previously obtained through prop=info",
- 'gettoken' => 'If set, an unblock token will be returned, and no other action will be taken',
'reason' => 'Reason for unblock',
);
}
public function getResultProperties() {
return array(
'' => array(
- 'unblocktoken' => array(
- ApiBase::PROP_TYPE => 'string',
- ApiBase::PROP_NULLABLE => true
- ),
'id' => array(
ApiBase::PROP_TYPE => 'integer',
ApiBase::PROP_NULLABLE => true
$this->assertEquals( 'infinity', $block->mExpiry );
}
- /**
- * @dataProvider provideBlockUnblockAction
- */
- function testGetTokenUsingABlockingAction( $action ) {
- $data = $this->doApiRequest(
- array(
- 'action' => $action,
- 'user' => 'UTApiBlockee',
- 'gettoken' => '' ),
- null,
- false,
- self::$users['sysop']->user
- );
- $this->assertEquals( 34, strlen( $data[0][$action]["{$action}token"] ) );
- }
-
/**
* Attempting to block without a token should give a UsageException with
* error message: