mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CookieWarning
synced 2024-11-23 22:03:41 +00:00
Use saveOption from module 'mediawiki.api.options'
The module 'mediawiki.api.options' is present since MediaWiki 1.25. Change-Id: I986afad78f8054596e0efe89aa9e663c6c123f03
This commit is contained in:
parent
5af96e1d18
commit
fc3d0012c7
|
@ -10,6 +10,9 @@
|
|||
"descriptionmsg": "cookiewarning-desc",
|
||||
"type": "other",
|
||||
"license-name": "MIT",
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.25.0"
|
||||
},
|
||||
"MessagesDirs": {
|
||||
"CookieWarning": [
|
||||
"i18n"
|
||||
|
@ -81,6 +84,7 @@
|
|||
"ext.CookieWarning": {
|
||||
"dependencies": [
|
||||
"mediawiki.api",
|
||||
"mediawiki.api.options",
|
||||
"mediawiki.cookie",
|
||||
"mediawiki.user"
|
||||
],
|
||||
|
|
|
@ -14,14 +14,12 @@
|
|||
// the user preferences.
|
||||
if ( !mw.user.isAnon() ) {
|
||||
// try to save, that the cookiewarning was disabled, in the user preferences
|
||||
new mw.Api().postWithToken( 'options', {
|
||||
action: 'options',
|
||||
change: 'cookiewarning_dismissed=1'
|
||||
} ).fail( function ( code, result ) {
|
||||
// if it fails, fall back to the cookie
|
||||
mw.log.warn( 'Failed to save dismissed CookieWarning: ' + code + '\n' + result.error + '. Using cookie now.' );
|
||||
setCookie();
|
||||
} );
|
||||
new mw.Api().saveOption( 'cookiewarning_dismissed', '1' )
|
||||
.fail( function ( code, result ) {
|
||||
// if it fails, fall back to the cookie
|
||||
mw.log.warn( 'Failed to save dismissed CookieWarning: ' + code + '\n' + result.error + '. Using cookie now.' );
|
||||
setCookie();
|
||||
} );
|
||||
} else {
|
||||
// use cookies for anonymous users
|
||||
setCookie();
|
||||
|
|
Loading…
Reference in a new issue