• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loader: do not load parent class after loading subclass

#1
I encounter it while using CI->loader->library(XXX) with a subclass.

I create a parent lib and a  sub lib in different file.

PHP Code:
class Parent_lib {
 
     public function test()
 
     {
 
           echo "Parent";
 
     }


PHP Code:
include_once('XXX');
class 
Sub_lib  extends Parent_Lib{
 
     public function test()
 
     {
 
           echo "Sub";
 
     }


It's OK when calling load->library('Sub_lib').

However, it will not load the Parent_lib when calling load->library('Parent_lib') somewhere after loading Sub_lib.

In my opinion,  it's better to check a duplicate loading just in _ci_init_library mothed.

PHP Code:
            if (class_exists($classFALSE))
            {
                
// Before we deem this to be a duplicate request, let's see
                // if a custom object name is being supplied. If so, we'll
                // return a new instance of the object
                
if ($object_name !== NULL)
                {
                    
$CI =& get_instance();
                    if ( ! isset(
$CI->$object_name))
                    {
                        return 
$this->_ci_init_library($class''$params$object_name);
                    }
                }

                
log_message('debug'$class.' class already loaded. Second attempt ignored.');
                return;
            } 


change to

PHP Code:
            if (class_exists($classFALSE))
            {
                
//do not check at here in case of object Inheritance
                
return $this->_ci_init_library($class''$params$object_name);
            } 


I have tried to fix it also with unittest, but there is no issue accociated with it.(https://github.com/bcit-ci/CodeIgniter/c...e?expand=1)

Could it be assigned to me after it is confirmed to be a bug?

Forgive my poor English, maybe, Chinglish(Chinese English.)
Reply

#2
You're inventing a new mechanism, based solely on your own preferences ... that's not a bug.
Reply

#3
(05-25-2016, 05:33 AM)Narf Wrote: You're inventing a new mechanism, based solely on your own preferences ... that's not a bug.

Thanks for your reminding ^_^
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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