• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI 3.1.3 subclassing CI_Lang does not work


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 


is executed I get an error

        // 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

        // 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

            // 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?


Libraries in core/ are always loaded, unconditionally.

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

Awesome! Thanks Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.