* (bug 28578) API's parse module should not silently override invalid
title inputs
* (bug 20699) API watchlist should list log-events
+* (bug 29070) Add token to action=watch
=== Languages updated in 1.19 ===
'unblock' => array( 'ApiQueryInfo', 'getUnblockToken' ),
'email' => array( 'ApiQueryInfo', 'getEmailToken' ),
'import' => array( 'ApiQueryInfo', 'getImportToken' ),
+ 'watch' => array( 'ApiQueryInfo', 'getWatchToken'),
);
wfRunHooks( 'APIQueryInfoTokens', array( &$this->tokenFunctions ) );
return $this->tokenFunctions;
return $cachedImportToken;
}
+ public static function getWatchToken( $pageid, $title ) {
+ global $wgUser;
+ if ( !$wgUser->isLoggedIn() ) {
+ return false;
+ }
+
+ static $cachedWatchToken = null;
+ if ( !is_null( $cachedWatchToken ) ) {
+ return $cachedWatchToken;
+ }
+
+ $cachedWatchToken = $wgUser->editToken( 'watch' );
+ return $cachedWatchToken;
+ }
+
public function execute() {
$this->params = $this->extractRequestParams();
if ( !is_null( $this->params['prop'] ) ) {
$this->getResult()->addValue( null, $this->getModuleName(), $res );
}
+ public function mustBePosted() {
+ return true;
+ }
+
public function isWriteMode() {
return true;
}
+ public function needsToken() {
+ return true;
+ }
+
+ public function getTokenSalt() {
+ return 'watch';
+ }
+
public function getAllowedParams() {
return array(
'title' => array(
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true
),
-
'unwatch' => false,
+ 'token' => null,
);
}
return array(
'title' => 'The page to (un)watch',
'unwatch' => 'If set the page will be unwatched rather than watched',
+ 'token' => 'A token previously acquired via prop=info',
);
}