Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/231888
Change subject: Fail gracefully when UploadWizard is disabled
......................................................................
Fail gracefully when UploadWizard is disabled
* Do not add id="upload-wizard" to the error message displayed when
UploadWizard is disabled.
* When no element with id="upload-wizard" is present, do not try to
build UI. (Previously it failed with cryptic errors deep in the code.)
Change-Id: I481dd11c233123ef92b3f3419c73c75a2f680e34
---
M includes/specials/SpecialUploadWizard.php
M resources/mw.UploadWizardPage.js
2 files changed, 8 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UploadWizard
refs/changes/88/231888/1
diff --git a/includes/specials/SpecialUploadWizard.php
b/includes/specials/SpecialUploadWizard.php
index f4e30f4..9c62288 100644
--- a/includes/specials/SpecialUploadWizard.php
+++ b/includes/specials/SpecialUploadWizard.php
@@ -327,8 +327,8 @@
if ( array_key_exists( 'fallbackToAltUploadForm', $config )
&& array_key_exists( 'altUploadForm', $config )
&& $config['altUploadForm'] != ''
- && $config[ 'fallbackToAltUploadForm' ]
) {
-
+ && $config[ 'fallbackToAltUploadForm' ]
+ ) {
$linkHtml = '';
$altUploadForm = Title::newFromText( $config[
'altUploadForm' ] );
if ( $altUploadForm instanceof Title ) {
@@ -342,7 +342,7 @@
return
Html::rawElement(
'div',
- array( 'id' => 'upload-wizard', 'class'
=> 'upload-section' ),
+ array(),
Html::rawElement(
'p',
array( 'style' => 'text-align:
center' ),
diff --git a/resources/mw.UploadWizardPage.js b/resources/mw.UploadWizardPage.js
index f02464f..d9a033f 100644
--- a/resources/mw.UploadWizardPage.js
+++ b/resources/mw.UploadWizardPage.js
@@ -16,6 +16,11 @@
// Default configuration value that cannot be removed
config.maxUploads = config.maxUploads || 10;
+
+ if ( $( '#upload-wizard' ).length === 0 ) {
+ mw.log( 'UploadWizard is disabled, nothing to do.' );
+ return;
+ }
uploadWizard = new mw.UploadWizard( config );
uploadWizard.createInterface( '#upload-wizard' );
--
To view, visit https://gerrit.wikimedia.org/r/231888
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I481dd11c233123ef92b3f3419c73c75a2f680e34
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits