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

[eluser]MikePearce[/eluser]
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:

Code:
/**
     * 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);
            }
        }
        else
        {
            $this->_ci_load_class($library, $params);
        }
        
        $this->_ci_assign_to_models();
    }

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,

Mike


Messages In This Thread
Autoloaded libraries loading loads - by El Forum - 02-01-2008, 11:07 AM
Autoloaded libraries loading loads - by El Forum - 02-04-2008, 01:44 AM
Autoloaded libraries loading loads - by El Forum - 02-04-2008, 02:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB