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:
Ed Sanders 2013-05-15 16:28:51 +01:00
parent 3109e96bb1
commit 201a1ac478
3 changed files with 8 additions and 5 deletions

View file

@ -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 );

View file

@ -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 );
};

View file

@ -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(