Welcome Guest, Not a member yet? Register   Sign In
Autoloaded libraries loading loads

Hi all,

I'm having a bit of a problem. I'm using an auto loaded library and it calls an external service to grab some data in it's __construct().

Anyway, it would seem that codeigniter either loads, or instantiates the autoload clases several times as it boots up.

If I add an mail() call to the library method in Loader.php:

     * Class Loader
     * This function lets users load and instantiate classes.
     * It is designed to be called from a user's app controllers.
     * @access    public
     * @param    string    the name of the class
     * @param    mixed    the optional parameters
     * @return    void
    function library($library = '', $params = NULL)
        if ($library == '')
            return FALSE;

        if (is_array($library))
            foreach ($library as $class)
            {mail('[email protected]', 'C: '. $class, '');
                $this->_ci_load_class($class, $params);
            $this->_ci_load_class($library, $params);

I get 18 emails PER autoloaded library. Does anyone know why it is showing this behaviour?

It's not limited to there either. If I add the call to a __destruct() in another library (say, the Output.php for example) it does the same thing. So, I guess it's not just auto loaded libraries.

I've tried setting a flag within the $CI object so that it sets the flag on the first execution of the external call and then checks to see if the flag ISN'T set before calling it again, but it seems to ignore the flag and run the call 18 times anyway.

I really hope someone can help because this is driving me batshit crazy!!

Thanks in advance,


Anyone? Wink

The only time I have seen that type of behaviour is when your application classes use the same names as codeigniter core classes. (reserved words)

Theme © iAndrew 2016 - Forum software by © MyBB