Follow up to I0d6c654a7354ba77e65e338423952a6a78c1150f.
I have also added a URL to a help page on mw.org.
Change-Id: Ie223930cfc313aff150e2dcfd70b74bf4360a8a8
public function getParamDescription() {
return array(
- 'token' => 'An options token previously obtained through the meta=userinfo',
+ 'token' => 'An options token previously obtained through the action=tokens',
'reset' => 'Resets all preferences to the site defaults',
'change' => 'Pipe-separated list of changes, formatted name=value (e.g. skin=vector), value cannot contain pipe characters',
'optionname' => 'A name of a option which should have an optionvalue set',
return '';
}
+ public function getHelpUrls() {
+ return 'https://www.mediawiki.org/wiki/API:Options';
+ }
+
public function getExamples() {
return array(
'api.php?action=options&reset=&token=123ABC',
return $cachedWatchToken;
}
+ public static function getOptionsToken( $pageid, $title ) {
+ global $wgUser;
+ if ( !$wgUser->isLoggedIn() ) {
+ return false;
+ }
+
+ static $cachedOptionsToken = null;
+ if ( !is_null( $cachedOptionsToken ) ) {
+ return $cachedOptionsToken;
+ }
+
+ $cachedOptionsToken = $wgUser->getEditToken();
+ return $cachedOptionsToken;
+ }
+
public function execute() {
$this->params = $this->extractRequestParams();
if ( !is_null( $this->params['prop'] ) ) {
$vals['options'] = $user->getOptions();
}
- if ( isset( $this->prop['optionstoken'] ) &&
- is_null( $this->getMain()->getRequest()->getVal( 'callback' ) )
- ) {
- $vals['optionstoken'] = $user->getEditToken( '', $this->getMain()->getRequest() );
- }
-
if ( isset( $this->prop['preferencestoken'] ) &&
is_null( $this->getMain()->getRequest()->getVal( 'callback' ) )
) {
'rights',
'changeablegroups',
'options',
- 'optionstoken',
'preferencestoken',
'editcount',
'ratelimits',
' rights - Lists all the rights the current user has',
' changeablegroups - Lists the groups the current user can add to and remove from',
' options - Lists all preferences the current user has set',
- ' optionstoken - Get a token to change current user\'s preferences',
' preferencestoken - Get a token to change current user\'s preferences',
' editcount - Adds the current user\'s edit count',
' ratelimits - Lists all rate limits applying to the current user',
wfProfileIn( __METHOD__ );
$types = array( 'patrol' => 'ApiQueryRecentChanges::getPatrolToken' );
$names = array( 'edit', 'delete', 'protect', 'move', 'block', 'unblock',
- 'email', 'import', 'watch' );
+ 'email', 'import', 'watch', 'options' );
foreach ( $names as $name ) {
- $types[$name] = 'ApiQUeryInfo::get' . ucfirst( $name ) . 'Token';
+ $types[$name] = 'ApiQueryInfo::get' . ucfirst( $name ) . 'Token';
}
wfRunHooks( 'ApiTokensGetTokenTypes', array( &$types ) );
ksort( $types );