Merge "Avoid INSERT..SELECT in doArticleDeleteReal()"
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.ForeignUpload.js
index aa08b6c..781c1df 100644 (file)
                // However, if the target is a remote wiki, we must check the API
                // to confirm that the target is one that this site is configured to
                // support.
-               if ( this.target === 'local' ) {
+               if ( validTargets.length === 0 ) {
+                       this.apiPromise = $.Deferred().reject( 'upload-dialog-disabled' );
+               } else if ( this.target === 'local' ) {
                        // If local uploads were requested, but they are disabled, fail.
                        if ( !mw.config.get( 'wgEnableUploads' ) ) {
-                               throw new Error( 'Local uploads are disabled' );
+                               this.apiPromise = $.Deferred().reject( 'uploaddisabledtext' );
+                       } else {
+                               // We'll ignore the CORS and centralauth stuff if the target is
+                               // the local wiki.
+                               this.apiPromise = $.Deferred().resolve( new mw.Api( apiconfig ) );
                        }
-                       // We'll ignore the CORS and centralauth stuff if the target is
-                       // the local wiki.
-                       this.apiPromise = $.Deferred().resolve( new mw.Api( apiconfig ) );
                } else {
                        api = new mw.Api();
                        this.apiPromise = api.get( {
@@ -76,7 +79,7 @@
                                        }
                                }
 
-                               throw new Error( 'Can not upload to requested foreign repo' );
+                               return $.Deferred().reject( 'upload-foreign-cant-upload' );
                        } );
                }
 
                // actual API call methods to wait for the apiPromise to resolve
                // before continuing.
                mw.Upload.call( this, null );
-
-               if ( this.target !== 'local' ) {
-                       // Keep these untranslated. We don't know the content language of the foreign wiki, best to
-                       // stick to English in the text.
-                       this.setComment( 'Cross-wiki upload from ' + location.host );
-               }
        }
 
        OO.inheritClass( ForeignUpload, mw.Upload );