mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
Better handling of read-only mode
* Don't just fail to load, action=visualeditor itself should not write to the DB (we have action=visualeditoredit for that) * Send notice to the client in the usual way * Handle read only errors on save, log as unknown This won't let you review changes because that uses visualeditoredit Bug: T129501 Change-Id: Id78c06b031423e47a7ddf94ec615b6d6975309d3
This commit is contained in:
parent
ada244c6f8
commit
d2a9aefba7
|
@ -381,6 +381,10 @@ class ApiVisualEditor extends ApiBase {
|
|||
$notices[] = $this->msg( 'editingold' )->parseAsBlock();
|
||||
}
|
||||
|
||||
if ( wfReadOnly() ) {
|
||||
$notices[] = $this->msg( 'readonlywarning', wfReadOnlyReason() );
|
||||
}
|
||||
|
||||
// New page notices
|
||||
if ( !$title->exists() ) {
|
||||
$notices[] = $this->msg(
|
||||
|
@ -698,6 +702,6 @@ class ApiVisualEditor extends ApiBase {
|
|||
}
|
||||
|
||||
public function isWriteMode() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,6 +360,7 @@
|
|||
"editing",
|
||||
"lastmodifiedat",
|
||||
"parentheses",
|
||||
"readonlywarning",
|
||||
"redirectpagesub",
|
||||
"visualeditor-loadwarning",
|
||||
"visualeditor-loadwarning-token",
|
||||
|
|
|
@ -135,6 +135,11 @@ OO.inheritClass( ve.init.mw.ArticleTarget, ve.init.mw.Target );
|
|||
* Fired when the user tries to save page in violation of the TitleBlacklist
|
||||
*/
|
||||
|
||||
/**
|
||||
* @event saveErrorReadOnly
|
||||
* Fired when the user tries to save page but the database is locked
|
||||
*/
|
||||
|
||||
/**
|
||||
* @event loadError
|
||||
*/
|
||||
|
@ -467,6 +472,9 @@ ve.init.mw.ArticleTarget.prototype.saveFail = function ( doc, saveData, jqXHR, s
|
|||
} else if ( data.error && data.error.code === 'titleblacklist-forbidden' ) {
|
||||
this.saveErrorTitleBlacklist();
|
||||
return;
|
||||
} else if ( data.error && data.error.code === 'readonly' ) {
|
||||
this.saveErrorReadOnly( data.error.readonlyreason );
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle captcha
|
||||
|
@ -741,6 +749,18 @@ ve.init.mw.ArticleTarget.prototype.saveErrorPageDeleted = function () {
|
|||
this.emit( 'saveErrorPageDeleted' );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle read only error
|
||||
*
|
||||
* @method
|
||||
* @param {string} reason The reason given by the system administrator.
|
||||
* @fires saveErrorReadOnly
|
||||
*/
|
||||
ve.init.mw.ArticleTarget.prototype.saveErrorReadOnly = function ( reason ) {
|
||||
this.showSaveError( $( $.parseHTML( mw.message( 'readonlywarning', reason ).parse() ) ), true, true );
|
||||
this.emit( 'saveErrorReadOnly' );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle an edit conflict
|
||||
*
|
||||
|
|
|
@ -31,6 +31,7 @@ ve.init.mw.ArticleTargetEvents = function VeInitMwArticleTargetEvents( target )
|
|||
saveErrorPageDeleted: [ 'trackSaveError', 'pagedeleted' ],
|
||||
saveErrorTitleBlacklist: [ 'trackSaveError', 'titleblacklist' ],
|
||||
saveErrorCaptcha: [ 'trackSaveError', 'captcha' ],
|
||||
saveErrorReadOnly: [ 'trackSaveError', 'unknown' ],
|
||||
saveErrorUnknown: [ 'trackSaveError', 'unknown' ],
|
||||
editConflict: [ 'trackSaveError', 'editconflict' ],
|
||||
surfaceReady: 'onSurfaceReady',
|
||||
|
|
Loading…
Reference in a new issue