Skip to content

Commit

Permalink
Add cache purge to edit conflict recovery logic
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleDouggie committed Apr 6, 2011
1 parent 6964cc6 commit 45ce088
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 203 deletions.
15 changes: 13 additions & 2 deletions morebits.js
Original file line number Diff line number Diff line change
Expand Up @@ -2186,9 +2186,20 @@ Wikipedia.page = function(pageName, currentAction) {
if ( errorCode == "editconflict" && ctx.conflictRetries++ < ctx.maxConflictRetries ) {

// alert("Edit conflict detected!");
ctx.statusElement.info("Edit conflict detected, retrying...");
--Wikipedia.numberOfActionsLeft; // allow for normal completion if retry succeeds
ctx.loadApi.post(); // reload

// edit conflicts can occur when the page needs to be purged from the server cache
var purgeQuery = {
action: 'purge',
titles: ctx.pageName // redirects are already resolved
};

var purgeApi = new Wikipedia.api("Edit conflict detected, purging server cache...", purgeQuery, ctx.statusElement);
purgeApi.post( { async: false } ); // just wait for it to complete
ctx.statusElement.info("Edit conflict detected, reapplying edit...");
--Wikipedia.numberOfActionsLeft; // compensate for use of |async: false|

ctx.loadApi.post(); // reload the page and reapply the edit

// check for loss of edit token
// it's impractical to request a new token here, so invoke edit conflict logic when this happens
Expand Down
Loading

0 comments on commit 45ce088

Please sign in to comment.