r42428 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r42427‎ | r42428 | r42429 >
Date:22:57, 23 October 2008
Author:tparscal
Status:old
Tags:
Comment:
Added draft token to javascript save draft functionality.
Modified paths:
  • /trunk/extensions/Drafts/Drafts.hooks.php (modified) (history)
  • /trunk/extensions/Drafts/Drafts.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Drafts/Drafts.hooks.php
@@ -221,11 +221,13 @@
222222 }
223223
224224 // Respond to ajax queries
225 -function efDraftsSave( $token, $id, $title, $section, $starttime, $edittime, $scrolltop, $text, $summary, $minoredit ) {
226 - global $wgUser;
 225+function efDraftsSave( $dtoken, $etoken, $id, $title, $section, $starttime, $edittime, $scrolltop, $text, $summary, $minoredit ) {
 226+ global $wgUser, $wgRequest;
227227
 228+ $wgRequest->setVal( 'wpDraftToken', $dtoken );
 229+
228230 // Verify token
229 - if ( $wgUser->editToken() == $token ) {
 231+ if ( $wgUser->editToken() == $etoken ) {
230232 // Create Draft
231233 $draft = Draft::newFromID( $id );
232234
Index: trunk/extensions/Drafts/Drafts.js
@@ -15,6 +15,7 @@
1616
1717 wgAjaxSaveDraft.save = function() {
1818 wgAjaxSaveDraft.call(
 19+ document.editform.wpDraftToken.value,
1920 document.editform.wpEditToken.value,
2021 document.editform.wpDraftID.value,
2122 document.editform.wpDraftTitle.value,
@@ -84,7 +85,7 @@
8586 }
8687 }
8788
88 -wgAjaxSaveDraft.call = function( token, id, title, section, starttime, edittime, scrolltop, text, summary, minoredit ) {
 89+wgAjaxSaveDraft.call = function( dtoken, etoken, id, title, section, starttime, edittime, scrolltop, text, summary, minoredit ) {
8990 // If in progress, exit now
9091 if( wgAjaxSaveDraft.inprogress )
9192 return;
@@ -95,7 +96,7 @@
9697 // Perform Ajax call
9798 sajax_do_call(
9899 "efDraftsSave",
99 - [ token, id, title, section, starttime, edittime, scrolltop, text, summary, minoredit ],
 100+ [ dtoken, etoken, id, title, section, starttime, edittime, scrolltop, text, summary, minoredit ],
100101 wgAjaxSaveDraft.processResult
101102 );
102103

Status & tagging log