r77849 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77848‎ | r77849 | r77850 >
Date:01:20, 6 December 2010
Author:werdna
Status:deferred
Tags:
Comment:
Get token from a gettoken parameter instead of by asking for a token from a random page
Modified paths:
  • /trunk/extensions/LiquidThreads/api/ApiThreadAction.php (modified) (history)
  • /trunk/extensions/LiquidThreads/lqt.js (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/api/ApiThreadAction.php
@@ -5,6 +5,13 @@
66 public function execute() {
77 $params = $this->extractRequestParams();
88
 9+ if ( isset( $params['gettoken'] ) ) {
 10+ global $wgUser;
 11+ $result = array( 'token' => $wgUser->editToken() );
 12+ $this->getResult()->addValue( null, 'threadaction', $result );
 13+ return;
 14+ }
 15+
916 if ( empty( $params['threadaction'] ) ) {
1017 $this->dieUsageMsg( array( 'missingparam', 'action' ) );
1118 }
@@ -917,6 +924,7 @@
918925 'value' => null,
919926 'method' => null,
920927 'operand' => null,
 928+ 'gettoken' => null,
921929 );
922930 }
923931
Index: trunk/extensions/LiquidThreads/lqt.js
@@ -886,16 +886,14 @@
887887 'getToken' : function( callback ) {
888888 var getTokenParams =
889889 {
890 - 'action' : 'query',
891 - 'prop' : 'info',
892 - 'intoken' : 'edit',
893 - 'titles' : 'Some Title',
 890+ 'action' : 'threadaction',
 891+ 'gettoken' : 'gettoken',
894892 'format' : 'json'
895893 };
896894
897 - $j.get( wgScriptPath+'/api'+wgScriptExtension, getTokenParams,
 895+ $j.post( wgScriptPath+'/api'+wgScriptExtension, getTokenParams,
898896 function( data ) {
899 - var token = data.query.pages[-1].edittoken;
 897+ var token = data.threadaction.token;
900898
901899 callback(token);
902900 }, 'json' );

Status & tagging log