Revert "mediawiki.api: Use action=query&meta=tokens instead of action=tokens"
[lhc/web/wiklou.git] / resources / src / mediawiki.api / mediawiki.api.js
index b85c8e8..3a19e02 100644 (file)
         *         console.log( data );
         *     } );
         *
+        * Multiple values for a parameter can be specified using an array (since MW 1.25):
+        *
+        *     var api = new mw.Api();
+        *     api.get( {
+        *         action: 'query',
+        *         meta: [ 'userinfo', 'siteinfo' ] // same effect as 'userinfo|siteinfo'
+        *     } ).done ( function ( data ) {
+        *         console.log( data );
+        *     } );
+        *
         * @class
         *
         * @constructor
                                delete parameters.token;
                        }
 
+                       for ( key in parameters ) {
+                               if ( $.isArray( parameters[key] ) ) {
+                                       parameters[key] = parameters[key].join( '|' );
+                               }
+                       }
+
                        // If multipart/form-data has been requested and emulation is possible, emulate it
                        if (
                                ajaxOptions.type === 'POST' &&
                postWithToken: function ( tokenType, params, ajaxOptions ) {
                        var api = this;
 
-                       // Do not allow deprecated ok-callback
-                       // FIXME: Remove this check when the deprecated ok-callback is removed in #post
-                       if ( $.isFunction( ajaxOptions ) ) {
-                               ajaxOptions = undefined;
-                       }
-
                        return api.getToken( tokenType, params.assert ).then( function ( token ) {
                                params.token = token;
                                return api.post( params, ajaxOptions ).then(
                'nomodule',
                'mustbeposted',
                'badaccess-groups',
-               'stashfailed',
                'missingresult',
                'missingparam',
                'invalid-file-key',
                'fetchfileerror',
                'fileexists-shared-forbidden',
                'invalidtitle',
-               'notloggedin'
+               'notloggedin',
+
+               // Stash-specific errors - expanded
+               'stashfailed',
+               'stasherror',
+               'stashedfilenotfound',
+               'stashpathinvalid',
+               'stashfilestorage',
+               'stashzerolength',
+               'stashnotloggedin',
+               'stashwrongowner',
+               'stashnosuchfilekey'
        ];
 
        /**