Welcome Guest, Not a member yet? Register   Sign In
File helper in 2.0.1 not loading mimes array
#1

[eluser]Madmartigan1[/eluser]
I just "upgraded" to 2.0.1 this morning and found that the mimes array is not being loaded when calling get_mime_by_extension().

Code:
A PHP Error was encountered

Severity: Warning

Message: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object

Filename: helpers/file_helper.php

Line Number: 361

There has been no change to the helper. Here is where the issue happens:

Code:
if ( ! function_exists('get_mime_by_extension'))
{
    function get_mime_by_extension($file)
    {
        $extension = strtolower(substr(strrchr($file, '.'), 1));

        global $mimes;

        if ( ! is_array($mimes))
        {
            if ( ! require_once(APPPATH.'config/mimes.php'))
            {
                return FALSE;
            }
        }

exit(var_dump($mimes)); // returns NULL <--------------------------

        if (array_key_exists($extension, $mimes))
        {
            if (is_array($mimes[$extension]))
            {
                // Multiple mime types, just give the first one
                return current($mimes[$extension]);
            }
            else
            {
                return $mimes[$extension];
            }
        }
        else
        {
            return FALSE;
        }
    }
}

I tried this on a clean WAMP install, and updated my mimes.php (which did nothing).
Note that this was working in the last release.

Aside: There is also some Migrations junk in the main download which has been there for some time, and doesn't belong. Is it too much effort to remove it? Are things getting sloppy?


Messages In This Thread
File helper in 2.0.1 not loading mimes array - by El Forum - 03-26-2011, 08:38 AM
File helper in 2.0.1 not loading mimes array - by El Forum - 03-26-2011, 09:16 AM
File helper in 2.0.1 not loading mimes array - by El Forum - 03-31-2011, 11:28 AM
File helper in 2.0.1 not loading mimes array - by El Forum - 03-31-2011, 03:38 PM
File helper in 2.0.1 not loading mimes array - by El Forum - 04-01-2011, 02:35 AM
File helper in 2.0.1 not loading mimes array - by El Forum - 04-01-2011, 05:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB