From 201a1ac478baaa8aedb88a201612b98c00995761 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 15 May 2013 16:28:51 +0100 Subject: [PATCH] Return proper error if parsoid is unavailable on serialize Previously was just returning an empty result. Bug: 47581 Change-Id: I6bdd177bc9b5a0af9107cf08d8e46470c6778e12 --- ApiVisualEditor.php | 6 +++--- modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js | 1 - modules/ve/init/mw/ve.init.mw.Target.js | 6 +++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php index 0579119926..2cbd290632 100644 --- a/ApiVisualEditor.php +++ b/ApiVisualEditor.php @@ -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 ); diff --git a/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js b/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js index 50d15c9b8a..e94205fdf9 100644 --- a/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js @@ -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 ); }; diff --git a/modules/ve/init/mw/ve.init.mw.Target.js b/modules/ve/init/mw/ve.init.mw.Target.js index ce87f127c7..8fc90e1970 100644 --- a/modules/ve/init/mw/ve.init.mw.Target.js +++ b/modules/ve/init/mw/ve.init.mw.Target.js @@ -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(