Page MenuHomePhabricator

wgFileExtensions should always be a numerical array without gaps
Closed, ResolvedPublic

Description

This is a pathological case, but causes cryptic, poorly reported failure. If $wgFileExtensions contains a value in common with $wgFileBlacklist, UploadWizard refuses to upload files of any type.

This happens because Setup.php executes

$wgFileExtensions = array_diff ( $wgFileExtensions, $wgFileBlacklist );

and this creates an array with missing integer keys. This array is encoded for JavaScript by the Xml class as an Object rather than an Array, and the call to $j.inArray() that UploadWizard uses then fails on all files submitted.

To fix this, either Setup.php should use array_values( array_diff( ... ) ), or else UploadWizard.config.php should say

'fileExtensions' =>  array_values($wgFileExtensions),

Version: 1.20.x
Severity: normal

Details

Reference
bz44776

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 1:42 AM
bzimport set Reference to bz44776.

patch for UploadWizard.config.php

attachment patch ignored as obsolete

Thanks for the patch, you may also be interested in getting developer access[1] so you can get direct code review. Would you like to do that for this patch itself?

[1]http://www.mediawiki.org/wiki/Developer_access

OK, but I don't know the protocol. Feel free to email me with instructions.

You will learn that mostly in the account creation process. Besides you might find http://www.mediawiki.org/wiki/Git/Workflow helpful.

(In reply to comment #5)

OK. I did something that might be the right thing.
https://gerrit.wikimedia.org/r/#/c/48092/

That's the fastest someone has been with gerrit :)

2 hours to add bureaucracy to a 1-word patch is the fastest ever? Seems like a concern. Anyway, thanks for accepting the report and calling out for reviewers.

https://gerrit.wikimedia.org/r/#/c/50598/ now submitted, in response to comments on gerrit. This one adds array_values( ) to Setup.php, rather than to UploadWizard.config.php.

context for this bug report is at https://sourceforge.net/p/workingwiki/bugs/259 btw, though it's not necessary

Resolving since Gerrit change 50598 is now merged. In case it isn't solved yet, please reopen.

https://gerrit.wikimedia.org/r/48092 (Gerrit Change I46ff25baee72baafe0ff38d3e77fcb6a26f50090) | change ABANDONED [by Worden.lee]