mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-24 02:38:40 +00:00
Return proper error if parsoid is unavailable on serialize
Previously was just returning an empty result. Bug: 47581 Change-Id: I6bdd177bc9b5a0af9107cf08d8e46470c6778e12
This commit is contained in:
parent
3109e96bb1
commit
201a1ac478
|
@ -222,11 +222,11 @@ class ApiVisualEditor extends ApiBase {
|
|||
if ( $params['html'] === null ) {
|
||||
$this->dieUsageMsg( 'missingparam', 'html' );
|
||||
}
|
||||
$serialized = array( 'content' => $this->postHTML( $page, $params['html'], $parserParams ) );
|
||||
if ( $serialized === false ) {
|
||||
$content = $this->postHTML( $page, $params['html'], $parserParams );
|
||||
if ( $content === false ) {
|
||||
$this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' );
|
||||
} else {
|
||||
$result = array_merge( array( 'result' => 'success' ), $serialized );
|
||||
$result = array( 'result' => 'success', 'content' => $content );
|
||||
}
|
||||
} elseif ( $params['paction'] === 'save' || $params['paction'] === 'diff' ) {
|
||||
$wikitext = $this->postHTML( $page, $params['html'], $parserParams );
|
||||
|
|
|
@ -466,7 +466,6 @@ ve.init.mw.ViewPageTarget.prototype.onShowChangesError = function ( jqXHR, statu
|
|||
ve.init.mw.ViewPageTarget.prototype.onSerializeError = function ( jqXHR, status ) {
|
||||
alert( ve.msg( 'visualeditor-serializeerror', status ) );
|
||||
this.$saveDialogLoadingIcon.hide();
|
||||
this.saveDialogReviewGoodButton.setDisabled( false );
|
||||
this.saveDialogReviewWrongButton.setDisabled( false );
|
||||
};
|
||||
|
||||
|
|
|
@ -329,7 +329,11 @@ ve.init.mw.Target.onSerialize = function ( response ) {
|
|||
var data = response.visualeditor;
|
||||
if ( !data && !response.error ) {
|
||||
ve.init.mw.Target.onSerializeError.call( this, null, 'Invalid response from server', null );
|
||||
} else if ( response.error || data.result === 'error' ) {
|
||||
} else if ( response.error ) {
|
||||
ve.init.mw.Target.onSerializeError.call(
|
||||
this, null, 'Unsuccessful request: ' + response.error.info, null
|
||||
);
|
||||
} else if ( data.result === 'error' ) {
|
||||
ve.init.mw.Target.onSerializeError.call( this, null, 'Server error', null );
|
||||
} else if ( typeof data.content !== 'string' ) {
|
||||
ve.init.mw.Target.onSerializeError.call(
|
||||
|
|
Loading…
Reference in a new issue