? mimedetect-306217-20.patch
Index: README.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimedetect/README.txt,v
retrieving revision 1.1
diff -u -p -r1.1 README.txt
--- README.txt	5 Jan 2008 05:04:09 -0000	1.1
+++ README.txt	12 Sep 2009 17:01:18 -0000
@@ -4,4 +4,29 @@ then tries to use the MIME type supplied
 fails it will select a MIME type based on file extension. 
 
 MimeDetect is Distributed with a magic database to make FileInfo based MIME
-detection more consistent across servers. 
+detection more consistent across servers.
+
+Troubleshooting
+===============
+In some cases this database file, 'magic', does not work with your server. You
+have to use the 'magic' file of your distribution, which usually comes with
+File 4.x on your server.
+
+In your settings.php, you add a new variable that tells Mimedetect the
+absolute path of the magic file to use:
+  $conf = array(
+    'mimedetect_magic' => 'usr/share/file/magic',
+  );
+Replace 'usr/share/file' by the magic file path if it's different on your server.
+
+Note: if you're still having problems just creating a new PHP script outside of
+Drupal to test that you can load the database:
+<?php
+  $magic_file = '/usr/share/file/magic';
+  $finfo = finfo_open(FILEINFO_MIME, $magic_file);
+  if (!$finfo) {
+    echo "Opening fileinfo database failed";
+    exit();
+  }
+?>
+Replace 'usr/share/file' by the magic file path if it's different on your server.
Index: mimedetect.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimedetect/mimedetect.install,v
retrieving revision 1.7
diff -u -p -r1.7 mimedetect.install
--- mimedetect.install	15 Apr 2009 19:19:18 -0000	1.7
+++ mimedetect.install	12 Sep 2009 17:01:18 -0000
@@ -28,7 +28,7 @@ function mimedetect_requirements($phase)
 
   if (extension_loaded('fileinfo')) {
     $requirement['value'] = $t('PHP Fileinfo Extension');
-    if (!$finfo = @finfo_open(FILEINFO_MIME, drupal_get_path('module', 'mimedetect') .'/magic')) {
+    if (!$finfo = @finfo_open(FILEINFO_MIME, variable_get('mimedetect_magic', drupal_get_path('module', 'mimedetect') .'/magic'))) {
       $requirement['description'] = $t('Fileinfo could not load the magic file. It could be corrupted. Try reinstalling the magic file distributed with the MimeDetect module.');
       $requirement['severity'] = REQUIREMENT_ERROR;
     }
Index: mimedetect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimedetect/mimedetect.module,v
retrieving revision 1.10.2.1
diff -u -p -r1.10.2.1 mimedetect.module
--- mimedetect.module	9 May 2009 17:37:14 -0000	1.10.2.1
+++ mimedetect.module	12 Sep 2009 17:01:18 -0000
@@ -53,7 +53,7 @@ function mimedetect_mime($file) {
   );
 
   $mime = FALSE;
-  $magic_file = drupal_get_path('module', 'mimedetect') .'/magic';
+  $magic_file = variable_get('mimedetect_magic', drupal_get_path('module', 'mimedetect') .'/magic');
 
   // Try to use the fileinfo extension first.
   if (extension_loaded('fileinfo')) {
