mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CookieWarning
synced 2024-11-27 15:40:16 +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",
|
"descriptionmsg": "cookiewarning-desc",
|
||||||
"type": "other",
|
"type": "other",
|
||||||
"license-name": "MIT",
|
"license-name": "MIT",
|
||||||
|
"requires": {
|
||||||
|
"MediaWiki": ">= 1.25.0"
|
||||||
|
},
|
||||||
"MessagesDirs": {
|
"MessagesDirs": {
|
||||||
"CookieWarning": [
|
"CookieWarning": [
|
||||||
"i18n"
|
"i18n"
|
||||||
|
@ -81,6 +84,7 @@
|
||||||
"ext.CookieWarning": {
|
"ext.CookieWarning": {
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
"mediawiki.api",
|
"mediawiki.api",
|
||||||
|
"mediawiki.api.options",
|
||||||
"mediawiki.cookie",
|
"mediawiki.cookie",
|
||||||
"mediawiki.user"
|
"mediawiki.user"
|
||||||
],
|
],
|
||||||
|
|
|
@ -14,14 +14,12 @@
|
||||||
// the user preferences.
|
// the user preferences.
|
||||||
if ( !mw.user.isAnon() ) {
|
if ( !mw.user.isAnon() ) {
|
||||||
// try to save, that the cookiewarning was disabled, in the user preferences
|
// try to save, that the cookiewarning was disabled, in the user preferences
|
||||||
new mw.Api().postWithToken( 'options', {
|
new mw.Api().saveOption( 'cookiewarning_dismissed', '1' )
|
||||||
action: 'options',
|
.fail( function ( code, result ) {
|
||||||
change: 'cookiewarning_dismissed=1'
|
// if it fails, fall back to the cookie
|
||||||
} ).fail( function ( code, result ) {
|
mw.log.warn( 'Failed to save dismissed CookieWarning: ' + code + '\n' + result.error + '. Using cookie now.' );
|
||||||
// if it fails, fall back to the cookie
|
setCookie();
|
||||||
mw.log.warn( 'Failed to save dismissed CookieWarning: ' + code + '\n' + result.error + '. Using cookie now.' );
|
} );
|
||||||
setCookie();
|
|
||||||
} );
|
|
||||||
} else {
|
} else {
|
||||||
// use cookies for anonymous users
|
// use cookies for anonymous users
|
||||||
setCookie();
|
setCookie();
|
||||||
|
|
Loading…
Reference in a new issue