Changes to my team's database are recorded in our internal wiki. Currently, in addition to a brief description, the .sql scripts are added as text. This is becoming bulky and making the page difficult to read. I'm trying to configure mediawiki to allow .sql files to be uploaded, so they can just be linked to from the changes list.

I added 'sql' to the array of accept file extensions in LocalSettings.php. Attempting to upload a SQL script I get the following warning:

The file is corrupt or has an incorrect extension. Please check the file and upload again.

Uploading is already configured and works for the file types previously chosen. I've read several manual pages from MediaWiki, but they have not been able to help me resolve the problem. I found that some files may need to be white-listed, but .SQL was not in the $wgFileBlacklist or the $wgMimeTypeBlacklist. The configuring uploads article in the manual states this error could be due to MIME type detection not working correctly. Googling has also yielded no relevant answers.

How can I configure my mediawiki to allow .SQL file uploads?

What I'm working with:

  • MediaWiki 1.15.5-7
  • PHP 5.3.10-1ubuntu3.6 (apache2handler)
  • MySQL 5.5.29-0ubuntu0.12.04.2

First of all, see this page about your specific error message. The problem seems to be triggered by MIME type detection. Try setting $wgVerifyMimeType to false and see if it resolves the problem. If it does, you need to reconfigure $wgMimeTypeBlacklist.

If $wgStrictFileExtensions is set to true (and this is the default), only files with extensions listed in $wgFileExtensions will be allowed (whitelisting).

Just add in LocalSettings.php:

$wgFileExtensions[] = 'sql';

If that doesn't work, set $wgStrictFileExtensions to false temporarily (this can expose you to security risks).

To disable all security checks on files, set $wgCheckFileExtensions to false.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.