Ticket #683 (closed defect: fixed)
[sfDoctrine] Column agregation - setSublcasses() causes Segmentation faults
| Reported by: | adrive | Owned by: | zYne- |
|---|---|---|---|
| Priority: | major | Milestone: | 2.0.0 (OLD) |
| Component: | Other | Version: | |
| Severity: | Keywords: | ||
| Cc: | jackbravo | Has Test: | |
| Status: | Has Patch: |
Description
Column aggregation works fine, but not in symfony project. After some self investigatings i did'n found something, that should cause segmentation faults. Maybe that's because I didn't understand well the core of doctrine internals.
I thought, that I have problem with php-5.2.0 on debian etch, later with php-5.2.3 on lenny, but I also compile php-5.2.5 myself, but segfault still occures.
I'll assume, you already have some symofny project with sfDoctrinePlugin and database configured correctly.
Here is simple schema.yml you will need to generate test models:
$ cat config/doctrine/schema.yml
Entity:
tableName: node
columns:
name:
type: varchar
size: 20
# used for column aggregation
type:
type: integer
size: 11
User:
inheritance:
extends: Entity
keyField: type
keyValue: 1
Group:
inheritance:
extends: Entity
keyField: type
keyValue: 2
$ symfony doctrine-build-model
>> doctrine Generated models successfully
Now there are three generated models - Entity, User, Group in lib/models/doctrine/generated. The base class for User looks like this:
abstract class BaseUser extends Entity
{
public function setTableDefinition()
{
parent::setTableDefinition();
}
public function setUp()
{
parent::setUp();
$this->setInheritanceMap(array('type' => '1'));
}
}
This is fine, and inheritance should work, but without Column agregation. If I select from Entity, I do not have User and Group instances in collection, but instances of Entity
For working column aggregation I need to define child classes to parent class via subclasses method.
So I edit user model in lib/models/doctrine/Entity.class.php to look like this:
class Entity extends BaseEntity
{
public function setTableDefinition()
{
parent::setTableDefinition();
$this->setSubclasses(array(
'User' => array('type'=> 1),
'Group' => array('type'=>2),
));
}
}
Now in some action try to create your first record (symfony module yourapp yourmodule;cd apps/yourapp/modules/yourmodule).
$ cat actions/actions.class.php
class testActions extends sfActions
{
public function executeIndex()
{
$user = new User();
$user->name = 'adrive';
$user->save();
}
}
Now when you execute your action you will find in your apache error log notice about segfault
$ tail /var/log/apache2/error.log ... [Mon Dec 17 16:29:43 2007] [notice] child pid 14609 exit signal Segmentation fault (11)
I try this on latest sfDoctrine (6540) with Doctrine (3279) and PHP versions mentioned above PHP 5.2.0-8+etch7, PHP 5.2.3-1+b1 (Lenny), and custom PHP 5.2.5 on Lenny.