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
This commit is contained in:
Brion Vibber 2013-09-25 12:52:00 -07:00 committed by Krinkle
parent aa6f866bd1
commit 3cfc7d5df1
5 changed files with 12 additions and 10 deletions

View file

@ -473,7 +473,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
global $wgFileExtensions; global $wgFileExtensions;
$data = array(); $data = array();
foreach ( $wgFileExtensions as $ext ) { foreach ( array_unique( $wgFileExtensions ) as $ext ) {
$data[] = array( 'ext' => $ext ); $data[] = array( 'ext' => $ext );
} }
$this->getResult()->setIndexedTagName( $data, 'fe' ); $this->getResult()->setIndexedTagName( $data, 'fe' );

View file

@ -504,7 +504,7 @@ class ApiUpload extends ApiBase {
case UploadBase::FILETYPE_BADTYPE: case UploadBase::FILETYPE_BADTYPE:
$extradata = array( $extradata = array(
'filetype' => $verification['finalExt'], 'filetype' => $verification['finalExt'],
'allowed' => $wgFileExtensions 'allowed' => array_values( array_unique( $wgFileExtensions ) )
); );
$this->getResult()->setIndexedTagName( $extradata['allowed'], 'ext' ); $this->getResult()->setIndexedTagName( $extradata['allowed'], 'ext' );

View file

@ -84,7 +84,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
'wgNamespaceIds' => $namespaceIds, 'wgNamespaceIds' => $namespaceIds,
'wgSiteName' => $wgSitename, 'wgSiteName' => $wgSitename,
'wgFileExtensions' => array_values( $wgFileExtensions ), 'wgFileExtensions' => array_values( array_unique( $wgFileExtensions ) ),
'wgDBname' => $wgDBname, 'wgDBname' => $wgDBname,
// This sucks, it is only needed on Special:Upload, but I could // This sucks, it is only needed on Special:Upload, but I could
// not find a way to add vars only for a certain module // not find a way to add vars only for a certain module

View file

@ -570,8 +570,9 @@ class SpecialUpload extends SpecialPage {
} else { } else {
$msg->params( $details['finalExt'] ); $msg->params( $details['finalExt'] );
} }
$msg->params( $this->getLanguage()->commaList( $wgFileExtensions ), $extensions = array_unique( $wgFileExtensions );
count( $wgFileExtensions ) ); $msg->params( $this->getLanguage()->commaList( $extensions ),
count( $extensions ) );
// Add PLURAL support for the first parameter. This results // Add PLURAL support for the first parameter. This results
// in a bit unlogical parameter sequence, but does not break // in a bit unlogical parameter sequence, but does not break
@ -877,16 +878,16 @@ class UploadForm extends HTMLForm {
# Everything not permitted is banned # Everything not permitted is banned
$extensionsList = $extensionsList =
'<div id="mw-upload-permitted">' . '<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"; "</div>\n";
} else { } else {
# We have to list both preferred and prohibited # We have to list both preferred and prohibited
$extensionsList = $extensionsList =
'<div id="mw-upload-preferred">' . '<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>\n" .
'<div id="mw-upload-prohibited">' . '<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"; "</div>\n";
} }
} else { } else {

View file

@ -618,9 +618,10 @@ abstract class UploadBase {
// Check whether the file extension is on the unwanted list // Check whether the file extension is on the unwanted list
global $wgCheckFileExtensions, $wgFileExtensions; global $wgCheckFileExtensions, $wgFileExtensions;
if ( $wgCheckFileExtensions ) { 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, $warnings['filetype-unwanted-type'] = array( $this->mFinalExtension,
$wgLang->commaList( $wgFileExtensions ), count( $wgFileExtensions ) ); $wgLang->commaList( $extensions ), count( $extensions ) );
} }
} }