Multiple Objects Of Class Created In One Object Initialization

Hello,

I recently re-organized my application code-base into several modules and nested sub-modules. I imported all the appropriate paths and added these modules/sub-modules in the configuration file as well. Immediately following this change, something strange is happening. Anytime I instantiate one new object of some of the classes, two or more objects of that class are created and a save() on that object inserts two or more identical records of the object in the DB as well. That is, if i do


$model = new Model()

and look at the object in NetBeans, two or more CLASSNAME strings of that class appear. As I move through the code, the number of CLASSNAME strings sometime increases. Ultimately, when the save() is called on the object, two or more of these identical records are saved in DB. This happens only with a few classes and these classes are in different modules/sub-modules.

The only common thread across these classes is that public class variables are declared in them. If I comment out the public class variables, initialize a new object and save it, things work fine. For all classes that don’t have any public class variables, everything works as it should.

When debugging a new object initialization, I tried stepping into YiiBase::autoload() function but couldn’t track the problem. After several hours, I am quite clueless about what is happening. Can someone please help?

Thank you.

Below are new observations related to the issue described, though none of them have gotten me closer to resolving the issue:

  1. The issue (of multiple records being inserted when one object of a model is instantiated and saved) seems to occur before the re-organization of code into modules & sub-modules too, so this is not the source of the problem.

  2. Public class variables declared in a class do not always lead to this issue coming up. That is, there are some classes with class variables but behave correctly when instantiated. Conversely, the issue does not seem to come up with classes that don’t have any public class variables or in classes that previously had the problem but the public variables are commented out.

At this point, I don’t know if it’s an issue related php or Yii or my application code but seems quite serious. Any help would be greatly appreciated. Thanks.