diff --git a/modules/ve-mw/init/ve.init.mw.ApiResponseCache.js b/modules/ve-mw/init/ve.init.mw.ApiResponseCache.js index 03f2fbe476..d2d6419662 100644 --- a/modules/ve-mw/init/ve.init.mw.ApiResponseCache.js +++ b/modules/ve-mw/init/ve.init.mw.ApiResponseCache.js @@ -14,11 +14,14 @@ * @class * @extends OO.EventEmitter * @constructor + * @param {mw.Api} [api] API object to use. Defaults to new mw.Api() */ -ve.init.mw.ApiResponseCache = function VeInitMwApiResponseCache() { +ve.init.mw.ApiResponseCache = function VeInitMwApiResponseCache( api ) { // Mixin constructor OO.EventEmitter.call( this ); + this.api = api || new mw.Api(); + // Keys are titles, values are deferreds this.deferreds = {}; diff --git a/modules/ve-mw/init/ve.init.mw.GalleryImageInfoCache.js b/modules/ve-mw/init/ve.init.mw.GalleryImageInfoCache.js index 743e4c0f79..f53a838ebf 100644 --- a/modules/ve-mw/init/ve.init.mw.GalleryImageInfoCache.js +++ b/modules/ve-mw/init/ve.init.mw.GalleryImageInfoCache.js @@ -11,9 +11,11 @@ * @class * @extends ve.init.mw.ImageInfoCache * @constructor + * @param {mw.Api} [api] */ ve.init.mw.GalleryImageInfoCache = function VeInitMwGalleryImageInfoCache() { - ve.init.mw.GalleryImageInfoCache.super.call( this ); + // Parent constructor + ve.init.mw.GalleryImageInfoCache.super.apply( this, arguments ); }; /* Inheritance */ @@ -26,7 +28,7 @@ OO.inheritClass( ve.init.mw.GalleryImageInfoCache, ve.init.mw.ImageInfoCache ); * @inheritdoc */ ve.init.mw.GalleryImageInfoCache.prototype.getRequestPromise = function ( subqueue ) { - return new mw.Api().get( + return this.api.get( { action: 'query', prop: 'imageinfo', diff --git a/modules/ve-mw/init/ve.init.mw.ImageInfoCache.js b/modules/ve-mw/init/ve.init.mw.ImageInfoCache.js index 478bdb1c34..68d17369da 100644 --- a/modules/ve-mw/init/ve.init.mw.ImageInfoCache.js +++ b/modules/ve-mw/init/ve.init.mw.ImageInfoCache.js @@ -11,9 +11,11 @@ * @class * @extends ve.init.mw.ApiResponseCache * @constructor + * @param {mw.Api} [api] */ ve.init.mw.ImageInfoCache = function VeInitMwImageInfoCache() { - ve.init.mw.ImageInfoCache.super.call( this ); + // Parent constructor + ve.init.mw.ImageInfoCache.super.apply( this, arguments ); }; /* Inheritance */ @@ -41,7 +43,7 @@ ve.init.mw.ImageInfoCache.static.processPage = function ( page ) { ve.init.mw.ImageInfoCache.prototype.getRequestPromise = function ( subqueue ) { // If you change what `iiprop`s are being fetched, update // ve.ui.MWMediaDialog to add the same ones to the cache. - return new mw.Api().get( + return this.api.get( { action: 'query', prop: 'imageinfo', diff --git a/modules/ve-mw/init/ve.init.mw.LinkCache.js b/modules/ve-mw/init/ve.init.mw.LinkCache.js index 4abe29e342..c22c32ba6b 100644 --- a/modules/ve-mw/init/ve.init.mw.LinkCache.js +++ b/modules/ve-mw/init/ve.init.mw.LinkCache.js @@ -11,9 +11,11 @@ * @class * @extends ve.init.mw.ApiResponseCache * @constructor + * @param {mw.Api} [api] */ ve.init.mw.LinkCache = function VeInitMwLinkCache() { - ve.init.mw.LinkCache.super.call( this ); + // Parent constructor + ve.init.mw.LinkCache.super.apply( this, arguments ); // Keys are page names, values are link data objects // This is kept for synchronous retrieval of cached values via #getCached @@ -184,7 +186,7 @@ ve.init.mw.LinkCache.prototype.get = function ( title ) { * @inheritdoc */ ve.init.mw.LinkCache.prototype.getRequestPromise = function ( subqueue ) { - return new mw.Api().get( { + return this.api.get( { action: 'query', prop: 'info|pageprops|pageimages|description', pithumbsize: 80,