jenkins-bot has submitted this change and it was merged.
Change subject: Remove duplicate file extensions from output messages
......................................................................
Remove duplicate file extensions from output messages
If a file type was added to $wgFileExtensions by both local configuration
and defaults in an extension (eg TimedMediaHandler and LocalSettings.php
both adding 'ogg' and 'ogv') it was being listed twice in the UI messages
listing acceptable types.
Runs array_unique() over the array on various outputs.
Bug: 54378
Change-Id: I14cd098d8b27099f8f803630535f33549740295c
---
M includes/api/ApiQuerySiteinfo.php
M includes/api/ApiUpload.php
M includes/resourceloader/ResourceLoaderStartUpModule.php
M includes/specials/SpecialUpload.php
M includes/upload/UploadBase.php
5 files changed, 12 insertions(+), 10 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/api/ApiQuerySiteinfo.php
b/includes/api/ApiQuerySiteinfo.php
index 3c22a73..fbba98c 100644
--- a/includes/api/ApiQuerySiteinfo.php
+++ b/includes/api/ApiQuerySiteinfo.php
@@ -473,7 +473,7 @@
global $wgFileExtensions;
$data = array();
- foreach ( $wgFileExtensions as $ext ) {
+ foreach ( array_unique( $wgFileExtensions ) as $ext ) {
$data[] = array( 'ext' => $ext );
}
$this->getResult()->setIndexedTagName( $data, 'fe' );
diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php
index 6f6b080..467eccf 100644
--- a/includes/api/ApiUpload.php
+++ b/includes/api/ApiUpload.php
@@ -504,7 +504,7 @@
case UploadBase::FILETYPE_BADTYPE:
$extradata = array(
'filetype' => $verification['finalExt'],
- 'allowed' => $wgFileExtensions
+ 'allowed' => array_values(
array_unique( $wgFileExtensions ) )
);
$this->getResult()->setIndexedTagName(
$extradata['allowed'], 'ext' );
diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php
b/includes/resourceloader/ResourceLoaderStartUpModule.php
index 861ff18..64915e5 100644
--- a/includes/resourceloader/ResourceLoaderStartUpModule.php
+++ b/includes/resourceloader/ResourceLoaderStartUpModule.php
@@ -84,7 +84,7 @@
'wgFormattedNamespaces' =>
$wgContLang->getFormattedNamespaces(),
'wgNamespaceIds' => $namespaceIds,
'wgSiteName' => $wgSitename,
- 'wgFileExtensions' => array_values( $wgFileExtensions ),
+ 'wgFileExtensions' => array_values( array_unique(
$wgFileExtensions ) ),
'wgDBname' => $wgDBname,
// This sucks, it is only needed on Special:Upload, but
I could
// not find a way to add vars only for a certain module
diff --git a/includes/specials/SpecialUpload.php
b/includes/specials/SpecialUpload.php
index 985de80..51a0a86 100644
--- a/includes/specials/SpecialUpload.php
+++ b/includes/specials/SpecialUpload.php
@@ -570,8 +570,9 @@
} else {
$msg->params( $details['finalExt'] );
}
- $msg->params( $this->getLanguage()->commaList(
$wgFileExtensions ),
- count( $wgFileExtensions ) );
+ $extensions = array_unique( $wgFileExtensions );
+ $msg->params( $this->getLanguage()->commaList(
$extensions ),
+ count( $extensions ) );
// Add PLURAL support for the first parameter.
This results
// in a bit unlogical parameter sequence, but
does not break
@@ -877,16 +878,16 @@
# Everything not permitted is banned
$extensionsList =
'<div id="mw-upload-permitted">' .
- $this->msg( 'upload-permitted',
$this->getContext()->getLanguage()->commaList( $wgFileExtensions )
)->parseAsBlock() .
+ $this->msg( 'upload-permitted',
$this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions
) ) )->parseAsBlock() .
"</div>\n";
} else {
# We have to list both preferred and prohibited
$extensionsList =
'<div id="mw-upload-preferred">' .
- $this->msg( 'upload-preferred',
$this->getContext()->getLanguage()->commaList( $wgFileExtensions )
)->parseAsBlock() .
+ $this->msg( 'upload-preferred',
$this->getContext()->getLanguage()->commaList( array_unique( $wgFileExtensions
) ) )->parseAsBlock() .
"</div>\n" .
'<div id="mw-upload-prohibited">' .
- $this->msg(
'upload-prohibited', $this->getContext()->getLanguage()->commaList(
$wgFileBlacklist ) )->parseAsBlock() .
+ $this->msg(
'upload-prohibited', $this->getContext()->getLanguage()->commaList(
array_unique( $wgFileBlacklist ) ) )->parseAsBlock() .
"</div>\n";
}
} else {
diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php
index 37dc7cb..4b8a562 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -618,9 +618,10 @@
// Check whether the file extension is on the unwanted list
global $wgCheckFileExtensions, $wgFileExtensions;
if ( $wgCheckFileExtensions ) {
- if ( !$this->checkFileExtension(
$this->mFinalExtension, $wgFileExtensions ) ) {
+ $extensions = array_unique( $wgFileExtensions );
+ if ( !$this->checkFileExtension(
$this->mFinalExtension, $extensions ) ) {
$warnings['filetype-unwanted-type'] = array(
$this->mFinalExtension,
- $wgLang->commaList( $wgFileExtensions
), count( $wgFileExtensions ) );
+ $wgLang->commaList( $extensions ),
count( $extensions ) );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/86021
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I14cd098d8b27099f8f803630535f33549740295c
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits