ApiVisualEditorEdit: Simplify diff handling a bit

I'm trying to track down possible values of 'result' for client-side
error handling and this was confusing.

Change-Id: I325249f7c57936c9c11a1d3dc9166b1ca3737c39
This commit is contained in:
Bartosz Dziewoński 2019-11-18 15:57:36 -05:00
parent 99cd4e26e9
commit 1e890f975f

View file

@ -353,7 +353,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
] );
if ( !isset( $result['compare']['*'] ) ) {
return [ 'result' => 'fail' ];
$this->dieWithError( 'apierror-visualeditor-difffailed', 'difffailed' );
}
$diffRows = $result['compare']['*'];
@ -408,11 +408,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
$result = [ 'result' => 'success', 'cachekey' => $key ];
} elseif ( $params['paction'] === 'diff' ) {
$section = $params['section'] ?? null;
$diff = $this->diffWikitext( $title, $params['oldid'], $wikitext, $section );
if ( $diff['result'] === 'fail' ) {
$this->dieWithError( 'apierror-visualeditor-difffailed', 'difffailed' );
}
$result = $diff;
$result = $this->diffWikitext( $title, $params['oldid'], $wikitext, $section );
} elseif ( $params['paction'] === 'save' ) {
$saveresult = $this->saveWikitext( $title, $wikitext, $params );
$editStatus = $saveresult['edit']['result'];