mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Check for the two revision IDs returned by the server being different
With RESTbase we'll be able to retry the older one, but right now we have to do both with the same request. This commit retries loading once, then starts emitting errors. Bug: T92993 Change-Id: Ifbf44b777279dafbe31ab438838d70acd44de726
This commit is contained in:
parent
8f012e76ce
commit
9019f02130
|
@ -301,7 +301,7 @@ ve.init.mw.Target.static.fixBase = function ( targetDoc, sourceDoc ) {
|
|||
* @fires loadError
|
||||
*/
|
||||
ve.init.mw.Target.onLoad = function ( response ) {
|
||||
var i, len, linkData,
|
||||
var i, len, linkData, aboutDoc, docRevId,
|
||||
data = response ? response.visualeditor : null;
|
||||
|
||||
if ( typeof data.content !== 'string' ) {
|
||||
|
@ -335,6 +335,26 @@ ve.init.mw.Target.onLoad = function ( response ) {
|
|||
this.startTimeStamp = data.starttimestamp;
|
||||
this.revid = data.oldid;
|
||||
|
||||
aboutDoc = this.doc.children[0].getAttribute( 'about' );
|
||||
docRevId = aboutDoc.match( /revision\/([0-9]*)$/ )[1];
|
||||
if ( Number.parseInt( docRevId ) !== this.revid ) {
|
||||
if ( this.retriedRevIdConflict ) {
|
||||
// Retried already, just error the second time.
|
||||
ve.init.mw.Target.onLoadError.call(
|
||||
this,
|
||||
've-api',
|
||||
'Revision IDs (doc=' + docRevId + ',api=' + this.revid + ') ' +
|
||||
'returned by server do not match'
|
||||
);
|
||||
} else {
|
||||
this.retriedRevIdConflict = true;
|
||||
// Have to retry both until we can access the document server directly...
|
||||
this.loading = false;
|
||||
this.load();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Populate link cache
|
||||
if ( data.links ) {
|
||||
// Format from the API: { missing: [titles], extant: true|[titles] }
|
||||
|
|
Loading…
Reference in a new issue