Update oldid on successful page save (if a new id is generated)

New ID is now passed from the API to the save event, to the onSave
handler. Empty diffs won't generate a newrevid.

Bug: 47420
Change-Id: I12ce27c8dc57f7aa753bcf5840635d5fea6b4e80
This commit is contained in:
Ed Sanders 2013-05-03 13:15:54 +01:00
parent d4d8e9075d
commit 33bfeeed41
3 changed files with 13 additions and 6 deletions

View file

@ -235,17 +235,20 @@ class ApiVisualEditor extends ApiBase {
'edit' => $editResult['edit']
);
} else {
if ( isset ( $editResult['edit']['newrevid'] ) && $wgVisualEditorUseChangeTagging ) {
if ( isset( $editResult['edit']['newrevid'] ) && $wgVisualEditorUseChangeTagging ) {
ChangeTags::addTags( 'visualeditor', null,
intval( $editResult['edit']['newrevid'] ),
null
);
}
$parsed = $this->parseWikitext( $page );
if ( $parsed === false ) {
$result = $this->parseWikitext( $page );
if ( $result === false ) {
$this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' );
}
$result = array_merge( array( 'result' => 'success' ), $parsed );
$result['result'] = 'success';
if ( isset( $editResult['edit']['newrevid'] ) ) {
$result['newrevid'] = intval( $editResult['edit']['newrevid'] );
}
}
} else if ( $params['paction'] === 'diff' ) {
$diff = $this->diffWikitext( $page, $wikitext );

View file

@ -331,8 +331,9 @@ ve.init.mw.ViewPageTarget.prototype.onLoadError = function ( response, status )
*
* @method
* @param {HTMLElement} html Rendered HTML from server
* @param {number} [newid] New revision id, undefined if unchanged
*/
ve.init.mw.ViewPageTarget.prototype.onSave = function ( html ) {
ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, newid ) {
if ( !this.pageExists || this.restoring ) {
// This is a page creation or restoration, refresh the page
this.tearDownBeforeUnloadHandler();
@ -353,6 +354,9 @@ ve.init.mw.ViewPageTarget.prototype.onSave = function ( html ) {
watchChecked ? 'unwatch': 'watch'
);
}
if ( newid !== undefined ) {
this.oldid = newid;
}
this.hideSaveDialog();
this.resetSaveDialog();
this.replacePageContent( html );

View file

@ -252,7 +252,7 @@ ve.init.mw.Target.onSave = function ( response ) {
this, null, 'Invalid HTML content in response from server', null
);
} else {
this.emit( 'save', data.content );
this.emit( 'save', data.content, data.newrevid );
}
};