Welcome Guest, Not a member yet? Register   Sign In
[library] Loader

[eluser]Peter Goodman[/eluser]
For some reason it seems that CI will include a library more than once if $this->load->library() is called for the same library. There are checks an balances in the code; however, they don't seem to be enough. This library provides a simple solution to the problem, and is something which I suggest should be implemented into CodeIgniter in the future.

Take note of the <subclass_prefix>


* Allow one to load the same library multiple times without
* the possibility of having an error that the class has already
* been declared.

class <sublcass_prefix>Loader extends CI_Loader {
    static private $loaded = array();
     * We don't actually need to know the class name or anything special
     * about it such as where it comes from. All that matters is that a
     * class with this name or something similar has been loaded.
    public function _ci_load_class($class, $params = NULL) {
        if(!in_array($class, self::$loaded)) {
            self::$loaded[] = $class;
            return parent::_ci_load_class($class, $params);

I remember reading something about this in the 1.5.4 update:

The link to the changelog on SVN

It says:

Quote:Fixed a bug that was allowing multiple load attempts on extended classes.

Is this the issue you are talking about?

[eluser]Peter Goodman[/eluser]
Yes, I have encountered this issue at work and I'm not 100% sure if we're using 1.5.4 or 1.5.3.

Theme © iAndrew 2016 - Forum software by © MyBB