Alex Monk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/259286
Change subject: Try to actually resolve visualeditor-editor preference setting
when switching editors
......................................................................
Try to actually resolve visualeditor-editor preference setting when switching
editors
Seems we need to make sure this returns before navigating to the target page.
This reverts commit 40807a07430ed777cb5f12cfe2bff8d0ff312ebc.
Bug: T121122
Change-Id: I4edf03bc0d57b03897d9f1802eabd8f0dd9962b9
---
M VisualEditor.hooks.php
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
3 files changed, 18 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/86/259286/1
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 3b522e7..2aa0c1c 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -75,7 +75,7 @@
$user->getOption( 'visualeditor-autodisable' ) ||
$user->getOption( 'visualeditor-tabs' ) === 'prefer-wt'
||
( $veConfig->get( 'VisualEditorDisableForAnons' ) &&
$user->isAnon() ) ||
- false // TODO: Detect incompatibility - P2373
+ false // TODO: Detect incompatibility - T121298, P2373
) {
return true;
}
@@ -102,13 +102,13 @@
$title->getContentModel() !== CONTENT_MODEL_WIKITEXT ||
// check for parameters that VE does not handle
// TODO: other params too? See identical list in
ve.init.mw.DesktopArticleTarget.init.js
- in_array( 'veswitched', $params ) ||
in_array( 'undo', $params ) ||
in_array( 'undoafter', $params ) ||
in_array( 'editintro', $params ) ||
in_array( 'preload', $params ) ||
in_array( 'preloadtitle', $params ) ||
in_array( 'preloadparams', $params );
+ // Known-good parameters: edit, veaction, section,
vesection, veswitched
}
/**
diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
index 8853582..a9b455f 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
@@ -235,8 +235,13 @@
}
$.cookie( 'VEE', editor, { path: '/', expires: 30 } );
- new mw.Api().saveOption( 'visualeditor-editor', editor );
- mw.user.options.set( 'visualeditor-editor', editor );
+ if ( mw.user.isAnon() ) {
+ return $.Deferred().resolve();
+ } else {
+ return new mw.Api().saveOption( 'visualeditor-editor',
editor ).then( function () {
+ mw.user.options.set( 'visualeditor-editor',
editor );
+ } );
+ }
}
function getLastEditor() {
@@ -714,13 +719,13 @@
)
)
) &&
- uri.query.veswitched === undefined &&
uri.query.undo === undefined &&
uri.query.undoafter === undefined &&
uri.query.editintro === undefined &&
uri.query.preload === undefined &&
uri.query.preloadtitle === undefined &&
uri.query.preloadparams === undefined
+ // Known-good parameters: edit, veaction,
section, vesection, veswitched
// TODO: other params too? See identical list
in VisualEditor.hooks.php
) {
trackActivateStart( {
diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
index 25ef674..46af75f 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
@@ -1371,8 +1371,8 @@
* @param {boolean} [modified] Whether there were any changes at all.
*/
ve.init.mw.DesktopArticleTarget.prototype.switchToWikitextEditor = function (
discardChanges, modified ) {
- var target = this;
- mw.libs.ve.setEditorPreference( 'wikitext' );
+ var target = this,
+ prefPromise = mw.libs.ve.setEditorPreference( 'wikitext' );
if ( discardChanges ) {
if ( modified ) {
@@ -1381,10 +1381,12 @@
ve.track( 'mwedit.abort', { type: 'switchnochange',
mechanism: 'navigate' } );
}
this.submitting = true;
- location.href = this.viewUri.clone().extend( {
- action: 'edit',
- veswitched: 1
- } ).toString();
+ prefPromise.done( function () {
+ location.href = this.viewUri.clone().extend( {
+ action: 'edit',
+ veswitched: 1
+ } ).toString();
+ }.bind( this ) );
} else {
this.serialize(
this.docToSave || this.getSurface().getDom(),
--
To view, visit https://gerrit.wikimedia.org/r/259286
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4edf03bc0d57b03897d9f1802eabd8f0dd9962b9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits