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:
parent
aa6f866bd1
commit
3cfc7d5df1
5 changed files with 12 additions and 10 deletions
|
|
@ -473,7 +473,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
|
|||
global $wgFileExtensions;
|
||||
|
||||
$data = array();
|
||||
foreach ( $wgFileExtensions as $ext ) {
|
||||
foreach ( array_unique( $wgFileExtensions ) as $ext ) {
|
||||
$data[] = array( 'ext' => $ext );
|
||||
}
|
||||
$this->getResult()->setIndexedTagName( $data, 'fe' );
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ class ApiUpload extends ApiBase {
|
|||
case UploadBase::FILETYPE_BADTYPE:
|
||||
$extradata = array(
|
||||
'filetype' => $verification['finalExt'],
|
||||
'allowed' => $wgFileExtensions
|
||||
'allowed' => array_values( array_unique( $wgFileExtensions ) )
|
||||
);
|
||||
$this->getResult()->setIndexedTagName( $extradata['allowed'], 'ext' );
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
|
|||
'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
|
||||
|
|
|
|||
|
|
@ -570,8 +570,9 @@ class SpecialUpload extends SpecialPage {
|
|||
} 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 @@ class UploadForm extends HTMLForm {
|
|||
# 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 {
|
||||
|
|
|
|||
|
|
@ -618,9 +618,10 @@ abstract class UploadBase {
|
|||
// 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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue