Use mw.cookie instead of jquery.cookie

jquery.cookie is no longer maintained, and we're coming up on maybe
running into issues with sameSite which jquery.cookie doesn't support.
Moving to mw.cookie will let us centralize that fix.

Also, removed some dependencies on jquery.cookie in code that doesn't
seem to ever use it.

Bug: T252597
Change-Id: I8634cfd42c2a5ab3c9d712417a7d1a55508274fd
This commit is contained in:
David Lynch 2020-07-30 11:42:18 -05:00
parent fd7912d2f6
commit deb218aeec
2 changed files with 5 additions and 7 deletions

View file

@ -358,7 +358,6 @@
},
"dependencies": [
"jquery.client",
"jquery.cookie",
"jquery.textSelection",
"mediawiki.page.startup",
"mediawiki.storage",
@ -366,6 +365,7 @@
"mediawiki.Uri",
"mediawiki.user",
"mediawiki.util",
"mediawiki.cookie",
"mediawiki.api",
"ext.visualEditor.supportCheck",
"ext.visualEditor.track",
@ -464,7 +464,6 @@
"ext.visualEditor.articleTarget",
"ext.visualEditor.desktopTarget",
"ext.visualEditor.mwextensions.desktop",
"jquery.cookie",
"mediawiki.jqueryMsg",
"mediawiki.util"
],
@ -1687,7 +1686,6 @@
"mediawiki.jqueryMsg",
"mediawiki.storage",
"mediawiki.pulsatingdot",
"jquery.cookie",
"mediawiki.skinning.content.parsoid",
"mediawiki.widgets",
"ext.visualEditor.switching",

View file

@ -326,7 +326,7 @@
$( '.mw-editsection a' ).text( getTabMessage( sectionKey ) );
}
$.cookie( 'VEE', editor, { path: '/', expires: 30 } );
mw.cookie.set( 'VEE', editor, { path: '/', expires: 30 * 86400, prefix: '' } );
// Save user preference if logged in
if (
@ -460,7 +460,7 @@
function getLastEditor() {
// This logic matches VisualEditorHooks::getLastEditor
var editor = $.cookie( 'VEE' );
var editor = mw.cookie.get( 'VEE', '' );
// Set editor to user's preference or site's default if …
if (
// … user is logged in,
@ -509,7 +509,7 @@
(
mw.user.isAnon() && (
mw.storage.get( storageKey ) ||
$.cookie( cookieName )
mw.cookie.get( cookieName, '' )
)
);
}
@ -520,7 +520,7 @@
if ( mw.user.isAnon() ) {
// Try local storage first; if that fails, set a cookie
if ( !mw.storage.set( storageKey, 1 ) ) {
$.cookie( cookieName, 1, { path: '/', expires: 30 } );
mw.cookie.set( cookieName, 1, { path: '/', expires: 30 * 86400, prefix: '' } );
}
} else {
new mw.Api().saveOption( prefName, '1' );