Community
Participate
Working Groups
For performance reasons, we should not be loading the class files each time we load the factory files. Thus we need to use dynamic loading and interfaces.
You can do this just by moving the require_once() calls into the function that instantiates an object. Sometimes you have to then hide the class name from the parser so it doesn't complain about not knowing about this class. I do this by saying something like: $classname = 'project_committer'; $class = new $classname($context); This will prevent the parser from complaining and still let us load the class dynamically.
I moved all of the require_once(...) calls inside around to reduce the runtime including (which is what this bug was all about) and created files for any objects that were in the same file as the factory. I addition I refactored all the factories to now use one base class (abstractfactory). Abstractfactory provides a generic getObjectForId,getObjectForContext and getActiveObjects implementation. Each object that a factory can create is wrapped inside of a create objects function ( like create_bugzilla_objects). That way we don't have to duplicate the security for creating objects (one for by context and another for by id). The functions getObjectsForContext and getObjectForId provided by abstractfactory both call a function in the factory called getObjects which then calls each private create function (like create_bugzilla_objects).
Released in STAGING_184