Page MenuHomePhabricator

Add variable to append/override mime.types contents
Open, LowPublicFeature

Description

Author: anon.hui

Description:
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.


Version: unspecified
Severity: enhancement

Details

Reference
bz18426

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 10:34 PM
bzimport set Reference to bz18426.
bzimport added a subscriber: Unknown Object (MLST).

anon.hui wrote:

Hmm, [[mediawikiwiki:Manual:$wgMimeTypeFile]] seems to do this task,
but it not allow specifying multiple files.

anon.hui wrote:

[[mw:Manual:$wgMimeTypeFile]]
[[mwwiki:Manual:$wgMimeTypeFile]]
[[mediawiki:Manual:$wgMimeTypeFile]]
http://www.mediawiki.org/wiki/Manual:$wgMimeTypeFile

anon.hui wrote:

It should allow specifying files in array like,

$wgMimeTypeFile = array("includes/mime.types", "/etc/mime.types", "/path/to/custom/mime.types");

anon.hui wrote:

$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";

anon.hui wrote:

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 );

anon.hui wrote:

(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.

Bryan.TongMinh wrote:

I believe that with $wgMimeTypeFile we have sufficient customization possibility.

anon.hui wrote:

(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

sumanah wrote:

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!

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:01 AM
Aklapper removed a subscriber: wikibugs-l-list.