Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/118733
Change subject: mediawiki.api: Remove deprecated function parameters
......................................................................
mediawiki.api: Remove deprecated function parameters
* 'ok' and 'err' parameters to various functions:
deprecated since MW 1.20, printing console warnings since MW 1.23
* 'async' parameter to mediawiki.api.category #getCategories:
deprecated and printing console warnings since MW 1.23
Change-Id: I0a650fdb4affd394ae419e21d54baf790116f6f7
---
M resources/mediawiki.api/mediawiki.api.category.js
M resources/mediawiki.api/mediawiki.api.parse.js
M resources/mediawiki.api/mediawiki.api.watch.js
3 files changed, 10 insertions(+), 68 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/33/118733/1
diff --git a/resources/mediawiki.api/mediawiki.api.category.js
b/resources/mediawiki.api/mediawiki.api.category.js
index 4859ce2..2ee48ed 100644
--- a/resources/mediawiki.api/mediawiki.api.category.js
+++ b/resources/mediawiki.api/mediawiki.api.category.js
@@ -3,29 +3,20 @@
*/
( function ( mw, $ ) {
- var msg = 'Use of mediawiki.api callback params is deprecated. Use the
Promise instead.';
$.extend( mw.Api.prototype, {
/**
* Determine if a category exists.
*
* @param {mw.Title|string} title
- * @param {Function} [ok] Success callback (deprecated)
- * @param {Function} [err] Error callback (deprecated)
* @return {jQuery.Promise}
* @return {Function} return.done
* @return {boolean} return.done.isCategory Whether the
category exists.
*/
- isCategory: function ( title, ok, err ) {
+ isCategory: function ( title ) {
var apiPromise = this.get( {
prop: 'categoryinfo',
titles: title.toString()
} );
-
- // Backwards compatibility (< MW 1.20)
- if ( ok || err ) {
- mw.track( 'mw.deprecate', 'api.cbParam' );
- mw.log.warn( msg );
- }
return apiPromise
.then( function ( data ) {
@@ -39,8 +30,6 @@
}
return exists;
} )
- .done( ok )
- .fail( err )
.promise( { abort: apiPromise.abort } );
},
@@ -50,25 +39,17 @@
* E.g. given "Foo", return "Food", "Foolish people", "Foosball
tables"...
*
* @param {string} prefix Prefix to match.
- * @param {Function} [ok] Success callback (deprecated)
- * @param {Function} [err] Error callback (deprecated)
* @return {jQuery.Promise}
* @return {Function} return.done
* @return {string[]} return.done.categories Matched categories
*/
- getCategoriesByPrefix: function ( prefix, ok, err ) {
+ getCategoriesByPrefix: function ( prefix ) {
// Fetch with allpages to only get categories that have
a corresponding description page.
var apiPromise = this.get( {
list: 'allpages',
apprefix: prefix,
apnamespace: mw.config.get( 'wgNamespaceIds'
).category
} );
-
- // Backwards compatibility (< MW 1.20)
- if ( ok || err ) {
- mw.track( 'mw.deprecate', 'api.cbParam' );
- mw.log.warn( msg );
- }
return apiPromise
.then( function ( data ) {
@@ -80,8 +61,6 @@
}
return texts;
} )
- .done( ok )
- .fail( err )
.promise( { abort: apiPromise.abort } );
},
@@ -89,32 +68,16 @@
* Get the categories that a particular page on the wiki
belongs to.
*
* @param {mw.Title} title
- * @param {Function} [ok] Success callback (deprecated)
- * @param {Function} [err] Error callback (deprecated)
- * @param {boolean} [async=true] Asynchronousness (deprecated)
* @return {jQuery.Promise}
* @return {Function} return.done
* @return {boolean|mw.Title[]} return.done.categories List of
category titles or false
* if title was not found.
*/
- getCategories: function ( title, ok, err, async ) {
+ getCategories: function ( title ) {
var apiPromise = this.get( {
prop: 'categories',
titles: title.toString()
- }, {
- async: async === undefined ? true : async
} );
-
- // Backwards compatibility (< MW 1.20)
- if ( ok || err ) {
- mw.track( 'mw.deprecate', 'api.cbParam' );
- mw.log.warn( msg );
- }
- // Backwards compatibility (< MW 1.23)
- if ( async !== undefined ) {
- mw.track( 'mw.deprecate', 'api.async' );
- mw.log.warn( 'Use of mediawiki.api async params
is deprecated' );
- }
return apiPromise
.then( function ( data ) {
@@ -133,8 +96,6 @@
}
return titles;
} )
- .done( ok )
- .fail( err )
.promise( { abort: apiPromise.abort } );
}
} );
diff --git a/resources/mediawiki.api/mediawiki.api.parse.js
b/resources/mediawiki.api/mediawiki.api.parse.js
index b1f1d2b..2dcf807 100644
--- a/resources/mediawiki.api/mediawiki.api.parse.js
+++ b/resources/mediawiki.api/mediawiki.api.parse.js
@@ -8,31 +8,21 @@
* Convenience method for 'action=parse'.
*
* @param {string} wikitext
- * @param {Function} [ok] Success callback (deprecated)
- * @param {Function} [err] Error callback (deprecated)
* @return {jQuery.Promise}
* @return {Function} return.done
* @return {string} return.done.data Parsed HTML of `wikitext`.
*/
- parse: function ( wikitext, ok, err ) {
+ parse: function ( wikitext ) {
var apiPromise = this.get( {
action: 'parse',
contentmodel: 'wikitext',
text: wikitext
} );
- // Backwards compatibility (< MW 1.20)
- if ( ok || err ) {
- mw.track( 'mw.deprecate', 'api.cbParam' );
- mw.log.warn( 'Use of mediawiki.api callback
params is deprecated. Use the Promise instead.' );
- }
-
return apiPromise
.then( function ( data ) {
return data.parse.text['*'];
} )
- .done( ok )
- .fail( err )
.promise( { abort: apiPromise.abort } );
}
} );
diff --git a/resources/mediawiki.api/mediawiki.api.watch.js
b/resources/mediawiki.api/mediawiki.api.watch.js
index aa33d86..1f4ee9b 100644
--- a/resources/mediawiki.api/mediawiki.api.watch.js
+++ b/resources/mediawiki.api/mediawiki.api.watch.js
@@ -12,8 +12,6 @@
* @param {string|mw.Title|string[]|mw.Title[]} pages Full page name or
instance of mw.Title, or an
* array thereof. If an array is passed, the return value passed to
the promise will also be an
* array of appropriate objects.
- * @param {Function} [ok] Success callback (deprecated)
- * @param {Function} [err] Error callback (deprecated)
* @return {jQuery.Promise}
* @return {Function} return.done
* @return {Object|Object[]} return.done.watch Object or list of
objects (depends on the `pages`
@@ -22,7 +20,7 @@
* @return {boolean} return.done.watch.watched Whether the page is now
watched or unwatched
* @return {string} return.done.watch.message Parsed HTML of the
confirmational interface message
*/
- function doWatchInternal( pages, ok, err, addParams ) {
+ function doWatchInternal( pages, addParams ) {
// XXX: Parameter addParams is undocumented because we inherit
this
// documentation in the public method...
var apiPromise = this.post(
@@ -37,19 +35,11 @@
)
);
- // Backwards compatibility (< MW 1.20)
- if ( ok || err ) {
- mw.track( 'mw.deprecate', 'api.cbParam' );
- mw.log.warn( 'Use of mediawiki.api callback params is
deprecated. Use the Promise instead.' );
- }
-
return apiPromise
.then( function ( data ) {
// If a single page was given (not an array)
respond with a single item as well.
return $.isArray( pages ) ? data.watch :
data.watch[0];
} )
- .done( ok )
- .fail( err )
.promise( { abort: apiPromise.abort } );
}
@@ -59,16 +49,17 @@
*
* @inheritdoc #doWatchInternal
*/
- watch: function ( pages, ok, err ) {
- return doWatchInternal.call( this, pages, ok, err );
+ watch: function ( pages ) {
+ return doWatchInternal.call( this, pages );
},
+
/**
* Convenience method for `action=watch&unwatch=1`.
*
* @inheritdoc #doWatchInternal
*/
- unwatch: function ( pages, ok, err ) {
- return doWatchInternal.call( this, pages, ok, err, {
unwatch: 1 } );
+ unwatch: function ( pages ) {
+ return doWatchInternal.call( this, pages, { unwatch: 1
} );
}
} );
--
To view, visit https://gerrit.wikimedia.org/r/118733
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a650fdb4affd394ae419e21d54baf790116f6f7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits