Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/62168


Change subject: Update oldid on successful page save (if a new id is generated)
......................................................................

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
---
M ApiVisualEditor.php
M modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js
M modules/ve/init/mw/ve.init.mw.Target.js
3 files changed, 13 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/68/62168/1

diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php
index 078f47f..5f6498b 100644
--- a/ApiVisualEditor.php
+++ b/ApiVisualEditor.php
@@ -235,17 +235,20 @@
                                                '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 );
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 fa3e94a..47c95a1 100644
--- a/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js
+++ b/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js
@@ -331,8 +331,9 @@
  *
  * @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 @@
                                watchChecked ? 'unwatch': 'watch'
                        );
                }
+               if ( newid !== undefined ) {
+                       this.oldid = newid;
+               }
                this.hideSaveDialog();
                this.resetSaveDialog();
                this.replacePageContent( html );
diff --git a/modules/ve/init/mw/ve.init.mw.Target.js 
b/modules/ve/init/mw/ve.init.mw.Target.js
index 6532e16..5cbc8f3 100644
--- a/modules/ve/init/mw/ve.init.mw.Target.js
+++ b/modules/ve/init/mw/ve.init.mw.Target.js
@@ -252,7 +252,7 @@
                        this, null, 'Invalid HTML content in response from 
server', null
                );
        } else {
-               this.emit( 'save', data.content );
+               this.emit( 'save', data.content, data.newrevid );
        }
 };
 

-- 
To view, visit https://gerrit.wikimedia.org/r/62168
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I12ce27c8dc57f7aa753bcf5840635d5fea6b4e80
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to