NMS 2.3 - Call to undefined method NMS::GetMimetype()

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
dwave
Forum Members
Forum Members
Posts: 39
Joined: Mon Aug 13, 2007 11:15 am
Location: Israel

NMS 2.3 - Call to undefined method NMS::GetMimetype()

Post by dwave »

Hi there,
CMSmadesimple and some of it's 3rd party have been working flawlessly for a couple of month. But since upgrading to 1.7 "Cape Verde" I stumbled upon the following error in NMS 2.3 when it tries to process jobs:

Code: Select all

Fatal error: Call to undefined method NMS::GetMimetype() in /kunden/200654_22609/webseiten/modules/NMS/NMS.module.php on line 691
Some background info on the server: PHP 5.2.13 (yes, I know, but it's on a manages host), CMSmadesimple 1.7, NMS 2.3; There is no magicfile provided in the PHP.INI. Could that be the source of the problem?

Best regards,
David
Last edited by dwave on Fri Apr 16, 2010 3:28 pm, edited 1 time in total.
--
dwave
Forum Members
Forum Members
Posts: 39
Joined: Mon Aug 13, 2007 11:15 am
Location: Israel

[solved?] Re: NMS 2.3 - Call to undefined method NMS::GetMimetype()

Post by dwave »

Kind of weird that I don't find any other reference in CMSmadesimple or in any of it's module to GetMimetype() yet none of the files of NMS 2.3 contains this function. I checked other installations of CMSms with NMS but I even there I didn't find anything about GetMimetype() .

In order to get NMS 2.3 to work I came up with a temporary and hackish solution:

1.) As the CMS ist hosted at a crappy managed host site that doesn't provide me PECL or mime magic, I uploaded a Apache mime types file on the webserver itself, outside the document root.

2.) I included my own Getmimetype() function as a workaround in NMS.module.php

Code: Select all

 /*---------------------------------------------------------
   Getmimetype
   -
   Retrieves the mim type of a given file.
   $mimePath must include path to Apache 2 mime types file
   ---------------------------------------------------------*/
function GetMimetype($filename, $mimePath = '/kunden/200654_22609') {
   $fileext = substr(strrchr($filename, '.'), 1);
   if (empty($fileext)) return (false);
   $regex = "/^([\w\+\-\.\/]+)\s+(\w+\s)*($fileext\s)/i";
   $lines = file("$mimePath/mime.types");
   foreach($lines as $line) {
      if (substr($line, 0, 1) == '#') continue; // skip comments
      $line = rtrim($line) . " ";
      if (!preg_match($regex, $line, $matches)) continue; // no match to the extension
      return ($matches[1]);
   }
   return (false); // no match at all
}
3.) Profit

I am aware that something must be wrong in a completely different place. Why would NMS 2.3 have missing functions? But for the time being this hack job above works surprisingly well and fixes the problem for now. (note to self: do some more Django again).
Last edited by dwave on Fri Apr 16, 2010 3:02 pm, edited 1 time in total.
--
Utter
Forum Members
Forum Members
Posts: 41
Joined: Sun Mar 06, 2005 11:39 pm

Re: NMS 2.3 - Call to undefined method NMS::GetMimetype()

Post by Utter »

NMS has been updated today (April 18) so i urge you to upgrade.

I was experiencing the same issue as above but after upgrading the module processes jobs as before and the error is gone.
dwave
Forum Members
Forum Members
Posts: 39
Joined: Mon Aug 13, 2007 11:15 am
Location: Israel

Re: NMS 2.3 - Call to undefined method NMS::GetMimetype()

Post by dwave »

Utter,
thank you for your reply. Yes, the issue is fixed with the update to NMS 2.2.3 and the module now uses the correct function get_mime_type() from cge_utils.
--
Post Reply

Return to “Modules/Add-Ons”