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?
#2

[eluser]Madmartigan1[/eluser]
I just grabbed the latest from bitbucket and the issue is resolved, and the Migrations file(s) have been removed.

I see the change from include_once to include has solved the issue, any idea what was causing it?

I see we can use a different mimetype config for different ENVIRONMENTs now...
Is that useful?

My concern remains that the download on the front page of codeigniter.com is borked.
Most people using CI for the first time will be downloading from that link.
Please, whoever is responsible, give the CI framework and community a good face by updating it with a more stable version without Phil Sturgeon's personal files included, even if a rollback to 2.0 is required.

Have a good day everyone Smile
#3

[eluser]Madmartigan1[/eluser]
Bumping this until the Migrations junk is cleaned up from the official download and the file helper is fixed.

There is no excuse for this laziness.
#4

[eluser]InsiteFX[/eluser]
You mean like did anyone test it for it's inputs and outputs before releasing it?

InsiteFX
#5

[eluser]Christopher Harrison[/eluser]
I upgraded a live site (the client is Mastercard) from 2.0.0 to 2.0.1. A few days later and they're asking why they can't access their files. Traced the bug to this thread.

I did this live upgrade because I've come to trust Codeigniter and I figured this upgrade would fix bugs and security - not make it worse.
#6

[eluser]InsiteFX[/eluser]
The last update in the Reactor at BitBucket has it fixed!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB