Third party igniter code, $ this-> load-> add_package_path does not work correctly

I am trying to use elliothaughins Socialize system for code igniter,

However i keep getting

Message: include (application / third_party / config / socializenetworks.php): could not open the stream: there is no such file or directory

I tracked this problem, and when I call $this->load->add_package_path(APPPATH.'third_party/socialize/');

In the loader class, if I do die($path) , I only get application/third_party .

Seems strange though the code for the controller

 class SocializeController extends CI_Controller { function __construct(){ parent::__construct(); parse_str($_SERVER['QUERY_STRING'], $_GET); $this->load->add_package_path(APPPATH.'third_party/socialize/'); $this->_autoload(); } private function _autoload(){ $this->load->model('socialize_migration_model'); $autoload = array(); include(APPPATH.'third_party/socialize/config/autoload'.EXT); foreach ( $autoload as $type => $files ) { $type = ($type == 'libraries') ? 'library' : $type; foreach ( $files as $file ){ $this->load->$type($file); } } } public function data($key, $value) { $this->load->vars(array($key => $value)); } } 

As you can see, this is a call to the model that it successfully loads, This is when it gets to the autoloader, where it loads the libraries, where it breaks,

The specific library that poses the problem starts as

 class SocializeNetworks { private $_obj; private $_networks = array(); function __construct(){ $this->_obj =& get_instance(); $this->_obj->load->config('socializenetworks'); // this is the line we die on :( 

So,

What is going on here and how can I fix it?

+4
source share
1 answer

I traced this to an error only yesterday in the CI v2.0.2 code base. Essentially, you add an additional path for checking files (this is correct), and the download method goes through each of the paths until it finds the file you are looking for.

If you output your CI object, you will probably see that what you are looking for is there, but it still does not work.

In the file /codeigniter/core/Config.php, where the download method for some reason is $ found = false; is not reset at each iteration along the path contour, therefore, if the path is found in the first run (as it was in my case), then $ found is set to true, but then in subsequent runs $ is still found true, so it tries to include a nonexistent file.

I solved this by moving the declaration for the $ found variable just below the start of the first foreach loop. Thus, he discards it every time. I reported an error, so I hope it will be considered in future versions.

+4
source

All Articles