mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
Try to make client and server code to get last editor work the same
On the client: getLastEditor in ve.init.mw.DesktopArticleTarget.init.js On the server: VisualEditorHooks::getUserEditor in VisualEditorHooks.php Change-Id: I9cc0f367aee2dda43cffc6918bfb042ac8ae3bb2
This commit is contained in:
parent
5508609124
commit
9170bd8acd
|
@ -180,15 +180,21 @@ class VisualEditorHooks {
|
|||
}
|
||||
|
||||
private static function getUserEditor( User $user, WebRequest $req ) {
|
||||
if ( $user->isAnon() ) {
|
||||
return $req->getCookie(
|
||||
'VEE',
|
||||
'',
|
||||
User::getDefaultOption( 'visualeditor-editor' )
|
||||
);
|
||||
} else {
|
||||
return $user->getOption( 'visualeditor-editor' );
|
||||
// This logic matches getLastEditor in:
|
||||
// modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
|
||||
$editor = $req->getCookie( 'VEE', '' );
|
||||
// Set editor to user's preference or site's default if …
|
||||
if (
|
||||
// … user is logged in,
|
||||
!$user->isAnon() ||
|
||||
// … no cookie is set, or
|
||||
!$editor ||
|
||||
// value is invalid.
|
||||
!( $editor === 'visualeditor' || $editor === 'wikitext' )
|
||||
) {
|
||||
$editor = $user->getOption( 'visualeditor-editor' );
|
||||
}
|
||||
return $editor;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -268,6 +268,7 @@
|
|||
}
|
||||
|
||||
function getLastEditor() {
|
||||
// This logic matches VisualEditorHooks::getUserEditor
|
||||
var editor = $.cookie( 'VEE' );
|
||||
// Set editor to user's preference or site's default if …
|
||||
if (
|
||||
|
|
Loading…
Reference in a new issue