Hello everyone, I upgraded my cakephp from 1.1.18 to 1.1.19.6305, I did a direct copy of cake directory and I found that it causes segmentation fault in my apache 2. After searching the entire web I couldn't find any solution about it other than the ones which says just get the latest copy and it will work. I decided to find a solution for it myself so I looked into cakephp's code and I found the problem with model_php5 file.
Here I will try to describe my situation and the (temporary) solution that I implemented for myself. Beware that this solution will modify the core cakephp model_php5 file so if you don't know what your doing then don't touch it. I only did it because my application uses lot of auto association and 1.1.18 didn't recursively fetch associations so I had to do something about it. I know it is not good to update the core files, but I know what is going on in there and I can always reverse it once new version of cakephp fixes the problem. Back to the problem. The problem is caused when you have a self referencing Model, cakephp goes into a bad recursion and causes segmentation fault. I have a model as following: class Category extends AppModel{ var $name = 'Category'; var $belongsTo = array( 'ParentCategory'=>array( 'className'=>'Category', 'foreignKey'=>'category_id' ) ); } As soon as cake php reaches this association in the __construct of model_php5 it tries to create the associations, instantiate the association classes and create their association, because ParentCategory is of type Category, it keeps looping in this association forever. The reason that it doesn't stop is because in model_php5's constructor at line 311 cakephp puts the alias of the object in the ClassRegistry like this: ClassRegistry::addObject($this->alias, $this); This is used to check if an object is created later on and it will avoid re-creating the object which cause the recursion. the value of $this->alias is "ParentCategory". When cakephp reaches line 466 it checks if the object is created or not with its class name ("category")! which of course never matches because originally the object was registered with its alias. I changed the code in model_php5 at line 466 from this: if (ClassRegistry::isKeySet($colKey)) { $this->{$assoc} = ClassRegistry::getObject($colKey); $this->{$className} = $this->{$assoc}; } to if (ClassRegistry::isKeySet($colKey) || ClassRegistry::isKeySet($model['alias'])) { if( ClassRegistry::isKeySet($colKey)) $this->{$assoc} = ClassRegistry::getObject($colKey); else $this->{$assoc} = ClassRegistry::getObject($model['alias']); $this->{$className} = $this->{$assoc}; } and it fixed the problem. I hope this helps someone. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---