Last modified: 2014-09-24 01:27:32 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T20426, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 18426 - Add variable to append/override mime.types contents
Add variable to append/override mime.types contents
Status: REOPENED
Product: MediaWiki
Classification: Unclassified
Uploading (Other open bugs)
unspecified
All All
: Low enhancement with 2 votes (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-04-10 18:45 UTC by Anon Sricharoenchai
Modified: 2014-09-24 01:27 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Anon Sricharoenchai 2009-04-10 18:45:41 UTC
There should be an option for sysadmin to put additional custom mime.types
entries separated from the initial "includes/mime.types" file.

Letting sysadmin to edit the file "includes/mime.types" is not a good idea,
since it will decrease the maintainability, especially when upgrading the
MediaWiki software.
The custom mime.types entries should be placed in a separate file.  The file
name may be specified in a variable, $wgCustomMimeTypes, for example.

This option is necessary, since the custom mime.types are still commonly needed, especially, openoffice document on redhat.
Eventhough the openoffice mimetype has been added in Bug 17497 (https://bugzilla.wikimedia.org/show_bug.cgi?id=17497), however, the command "file -bi" on Redhat, still return application/x-zip for openoffice files.
Comment 1 Anon Sricharoenchai 2009-09-18 08:09:49 UTC
Hmm, [[mediawikiwiki:Manual:$wgMimeTypeFile]] seems to do this task,
but it not allow specifying multiple files.
Comment 3 Anon Sricharoenchai 2009-09-18 08:16:43 UTC
It should allow specifying files in array like,

   $wgMimeTypeFile = array("includes/mime.types", "/etc/mime.types", "/path/to/custom/mime.types");
Comment 4 Anon Sricharoenchai 2009-09-18 09:04:37 UTC
$wgCustomMimeTypes may be used to override some mime types like this,

   $wgCustomMimeTypes = "application/x-zip odt
   application/x-zip ods
   application/x-zip odp
   application/x-zip jar";
Comment 5 Anon Sricharoenchai 2009-09-18 09:13:15 UTC
The code for comment #4, will look like this,

includes/MimeMagic.php:

        $types = MM_WELL_KNOWN_MIME_TYPES;

        if ( $wgMimeTypeFile == 'includes/mime.types' ) {
            $wgMimeTypeFile = "$IP/$wgMimeTypeFile";
        }

        if ( $wgMimeTypeFile ) {
            ...
                $types .= file_get_contents( $wgMimeTypeFile );
            ...
        } else {
            ...
        }

+       if ($wgCustomMimeTypes != "") $types .= "\n" . $wgCustomMimeTypes;

        $types = str_replace( array( "\r\n", "\n\r", "\n\n", "\r\r", "\r" ), "\n", $types );
        $types = str_replace( "\t", " ", $types );

Comment 6 Anon Sricharoenchai 2009-09-18 10:43:33 UTC
(In reply to comment #3)
> It should allow specifying files in array like,
> 
>    $wgMimeTypeFile = array("includes/mime.types", "/etc/mime.types",
> "/path/to/custom/mime.types");
> 

Since "includes/mime.types" and "/etc/mime.types" contains many duplicate entries,
it may result in unnecessary work load,
so it should be discouraged to load multiple files like this.
Comment 7 Bryan Tong Minh 2010-04-11 22:11:26 UTC
I believe that with $wgMimeTypeFile we have sufficient customization possibility.
Comment 8 Anon Sricharoenchai 2010-04-12 08:00:41 UTC
(In reply to comment #7)
> I believe that with $wgMimeTypeFile we have sufficient customization
> possibility.

it is insufficient, since we may need to append the customization to the upstream default
Comment 9 Sumana Harihareswara 2011-11-09 03:13:22 UTC
Anon Sricharoenchai, I'm removing the "patch" keyword since you haven't attached a patch per https://www.mediawiki.org/wiki/Patch#Posting_a_patch .  Please take a look at that page and consider contributing your fix as a patch against trunk.  Thanks!

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links