Welcome Guest, Not a member yet? Register   Sign In
CI 3.1.3 subclassing CI_Lang does not work
#1

Hey,

I did some testing with upgrading from 2.x to 3.x and I ran into an issue with subclassing of (core) CI_Lang with MY_Lang.

I can see that constructor of MY_Lang and CI_Lang are called, which is nice.

However if 

Code:
$ci->load->library('Lang',$pParams);

is executed I get an error

Code:
        // If we got this far we were unable to find the requested class.
        log_message('error', 'Unable to load the requested class: '.$class);
        show_error('Unable to load the requested class: '.$class);

The reason is that

Code:
        // Is this a stock library? There are a few special conditions if so ...
        if (file_exists(BASEPATH.'libraries/'.$subdir.$class.'.php'))
        {
            return $this->_ci_load_stock_library($class, $subdir, $params, $object_name);
        }


Is not executed because Lang is in directory '/core' and

Code:
            // Safety: Was the class already loaded by a previous call?
            if (class_exists($class, FALSE))

failes because class_exists('Lang') is not TRUE. It is TRUE for 'CI_Lang' and 'MY_Lang' though.


Am I missing something here? Any toughts?

Thanks!
Reply
#2

Libraries in core/ are always loaded, unconditionally.

Just don't call load->library() for them.
Reply
#3

Awesome! Thanks Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB