- global $wgRequest;
-
- if ( $session === null ) {
- $session = $wgRequest->getSessionArray();
- }
-
- if ( isset( $session['wsToken'] ) && $session['wsToken'] ) {
- // @todo Why does this directly mess with the session? Fix that.
- // add edit token to fake session
- $session['wsTokenSecrets']['default'] = $session['wsToken'];
- // add token to request parameters
- $timestamp = wfTimestamp();
- $params['token'] = hash_hmac( 'md5', $timestamp, $session['wsToken'] ) .
- dechex( $timestamp ) .
- MediaWiki\Session\Token::SUFFIX;
-
- return $this->doApiRequest( $params, $session, false, $user );
- } else {
- throw new Exception( "Session token not available" );
- }
+ return $this->doApiRequest( $params, $session, false, $user, $tokenType );