MWMediaResourceProvider: Use exist instead of bool check on API values

In the MediaWiki API, booleans exist or don't exist (with an empty string),
you can't check "if (bool)..." since that will always be false.  The API has
a newer formatversion=2 that fixes this but we're not using that yet.

Also update the defaultSource placeholder to match the API response. If one
would only update defaultSource without the 'if'-fix, one can reproduce T66822
on a local wiki (JSON-P request instead of JSON).

Bug: T66822
Change-Id: I5a8ab1136325c33c62982c0869fa14ca2fb26034
This commit is contained in:
Mark A. Hershberger 2015-06-10 20:44:26 -04:00 committed by Timo Tijhof
parent 85b86fb45d
commit 7d5e5ec9a9
2 changed files with 3 additions and 3 deletions

View file

@ -24,9 +24,9 @@ ve.dm.MWMediaResourceProvider = function VeDmMWMediaResourceProvider( apiurl, co
// Fetching configuration
this.scriptDirUrl = config.scriptDirUrl;
this.isLocal = config.local;
this.isLocal = ( 'local' in config );
if ( config.local ) {
if ( this.isLocal ) {
this.setAjaxSettings( {
url: mw.util.wikiScript( 'api' ),
// If the url is local use json

View file

@ -75,7 +75,7 @@ ve.dm.MWMediaResourceQueue.prototype.setup = function () {
ve.dm.MWMediaResourceQueue.prototype.getFileRepos = function () {
var defaultSource = [ {
url: mw.util.wikiScript( 'api' ),
local: true
local: ''
} ];
if ( !this.fileRepoPromise ) {