Remove gaps from $wgFileExtensions array
authorLee Worden <worden.lee@gmail.com>
Sun, 24 Feb 2013 07:15:11 +0000 (23:15 -0800)
committerKrinkle <ttijhof@wikimedia.org>
Sun, 24 Feb 2013 13:19:08 +0000 (13:19 +0000)
If $wgFileExtensions contains values that are in $wgFileBlacklist,
when Setup.php uses array_diff to remove them it leaves $wgFileExtensions
as an array with nonconsecutive integer indices.

When this array is encoded by the Xml class, for use in client-side
JavaScript, the nonconsecutive indices cause it to encode it as an
Object rather than Array.  This breaks the extension processing in
UploadWizard's JS code.  To fix this, use array_values to remove the
gaps in indices.

Bug: 44776
Change-Id: I4ef7f1de90a0384800722839f3fa3a581c63bac9

includes/Setup.php

index 7f4d634..0853df1 100644 (file)
@@ -337,7 +337,7 @@ if ( !$wgHtml5Version && $wgHtml5 && $wgAllowRdfaAttributes ) {
 }
 
 # Blacklisted file extensions shouldn't appear on the "allowed" list
-$wgFileExtensions = array_diff ( $wgFileExtensions, $wgFileBlacklist );
+$wgFileExtensions = array_values( array_diff ( $wgFileExtensions, $wgFileBlacklist ) );
 
 if ( $wgArticleCountMethod === null ) {
        $wgArticleCountMethod = $wgUseCommaCount ? 'comma' : 'link';