DDC-622: Caching ClassMetadata of an joined subclass with id generator sequence with apc and xml mapping #767

Closed
opened 2026-01-22 12:49:41 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Jun 2, 2010).

Jira issue originally created by user needle:

Apparently apc is having issues when storing an ClassMetadata object with sequenceGeneratorDefinition. When loading the object, apc seems to have lost this only field. I've just tested it with xml mapping.

Here is a fail test casse :

SecondClass and ThirdClass inherit from FirstClass

SQL

CREATE TABLE first_class
(
  id serial NOT NULL,
  "type" integer,
  CONSTRAINT first*class*pkey PRIMARY KEY (id)
);

CREATE TABLE second_class
(
  id serial NOT NULL,
  other_stuff character varying,
  CONSTRAINT second*class*pkey PRIMARY KEY (id)
);

CREATE TABLE third_class
(
  id serial NOT NULL,
  other_stuff character varying,
  CONSTRAINT third*class*pkey PRIMARY KEY (id)
);

Xml mapping :

<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

  <entity name="FirstClass" table='"first_class"' inheritance-type="JOINED">
    <id name="id" type="integer" column="id">
      <generator strategy="SEQUENCE"/>
      <sequence-generator sequence-name="first*class_id*seq" allocation-size="1" initial-value="1"/>
    </id>

    <discriminator-column name="type" type="integer" field-name="type" />

    <discriminator-map>
      <discriminator-mapping value="1" class="SecondClass" />
      <discriminator-mapping value="2" class="ThirdClass" />
    </discriminator-map>
  </entity>
</doctrine-mapping>

<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

  <entity name="SecondClass" table="second_class">
    <field name="otherStuff" column="other_stuff" type="string" />
  </entity>
</doctrine-mapping>

<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">

  <entity name="ThirdClass" table="second_class">
    <field name="otherStuff" column="other_stuff" type="string" />
  </entity>
</doctrine-mapping>

Php classes :

class FirstClass {

  private $id;
  private $type;
}

class SecondClass extends FirstClass {
  private $otherStuff;
}

class ThirdClass extends FirstClass {
  private $otherStuff;
}

First scipt to execute so that Doctrine store FirstClass metadata in cache :

$firstClass = new FirstClass();
$doctrineEntityManager->persist($firstClass);

$secondClass = new SecondClass();
$doctrineEntityManager->persist($secondClass);

and then we execute the last script :

$firstClass = new FirstClass();
$doctrineEntityManager->persist($firstClass);


$thirdClass = new ThirdClass();
$doctrineEntityManager->persist($thirdClass);

Obviously, Doctrine loads FirstClass Metadata from the cache and fails to create ThirdClass Metadata :

Catchable fatal error: Argument 1 passed to Doctrine\ORM\Mapping\ClassMetadataInfo::setSequenceGeneratorDefinition() must be an array, null given, called in doctrine/2.0.0-BETA1/Doctrine/ORM/Mapping/ClassMetadataFactory.php on line 269 and defined in doctrine/2.0.0-BETA1/Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 1222
Originally created by @doctrinebot on GitHub (Jun 2, 2010). Jira issue originally created by user needle: Apparently apc is having issues when storing an ClassMetadata object with sequenceGeneratorDefinition. When loading the object, apc seems to have lost this only field. I've just tested it with xml mapping. Here is a fail test casse : SecondClass and ThirdClass inherit from FirstClass SQL ``` CREATE TABLE first_class ( id serial NOT NULL, "type" integer, CONSTRAINT first*class*pkey PRIMARY KEY (id) ); CREATE TABLE second_class ( id serial NOT NULL, other_stuff character varying, CONSTRAINT second*class*pkey PRIMARY KEY (id) ); CREATE TABLE third_class ( id serial NOT NULL, other_stuff character varying, CONSTRAINT third*class*pkey PRIMARY KEY (id) ); ``` Xml mapping : ``` <?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="FirstClass" table='"first_class"' inheritance-type="JOINED"> <id name="id" type="integer" column="id"> <generator strategy="SEQUENCE"/> <sequence-generator sequence-name="first*class_id*seq" allocation-size="1" initial-value="1"/> </id> <discriminator-column name="type" type="integer" field-name="type" /> <discriminator-map> <discriminator-mapping value="1" class="SecondClass" /> <discriminator-mapping value="2" class="ThirdClass" /> </discriminator-map> </entity> </doctrine-mapping> <?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="SecondClass" table="second_class"> <field name="otherStuff" column="other_stuff" type="string" /> </entity> </doctrine-mapping> <?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="ThirdClass" table="second_class"> <field name="otherStuff" column="other_stuff" type="string" /> </entity> </doctrine-mapping> ``` Php classes : ``` class FirstClass { private $id; private $type; } class SecondClass extends FirstClass { private $otherStuff; } class ThirdClass extends FirstClass { private $otherStuff; } ``` First scipt to execute so that Doctrine store FirstClass metadata in cache : ``` $firstClass = new FirstClass(); $doctrineEntityManager->persist($firstClass); $secondClass = new SecondClass(); $doctrineEntityManager->persist($secondClass); ``` and then we execute the last script : ``` $firstClass = new FirstClass(); $doctrineEntityManager->persist($firstClass); $thirdClass = new ThirdClass(); $doctrineEntityManager->persist($thirdClass); ``` Obviously, Doctrine loads FirstClass Metadata from the cache and fails to create ThirdClass Metadata : ``` Catchable fatal error: Argument 1 passed to Doctrine\ORM\Mapping\ClassMetadataInfo::setSequenceGeneratorDefinition() must be an array, null given, called in doctrine/2.0.0-BETA1/Doctrine/ORM/Mapping/ClassMetadataFactory.php on line 269 and defined in doctrine/2.0.0-BETA1/Doctrine/ORM/Mapping/ClassMetadataInfo.php on line 1222 ```
admin added the Bug label 2026-01-22 12:49:41 +01:00
admin closed this issue 2026-01-22 12:49:42 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jun 6, 2010):

Comment created by needle:

With a little more debug I found that juste doing :

unserialize(serialize($data));

On _doSave() method from ApcCache object make me lost the sequenceGeneratorDefinition field...

Any idea ?

@doctrinebot commented on GitHub (Jun 6, 2010): Comment created by needle: With a little more debug I found that juste doing : ``` unserialize(serialize($data)); ``` On _doSave() method from ApcCache object make me lost the sequenceGeneratorDefinition field... Any idea ?
Author
Owner

@doctrinebot commented on GitHub (Jun 6, 2010):

Comment created by romanb:

Yes, its a bug in ClassMetadata#**sleep. Will be fixed soon. Thanks for reporting.

@doctrinebot commented on GitHub (Jun 6, 2010): Comment created by romanb: Yes, its a bug in ClassMetadata#**sleep. Will be fixed soon. Thanks for reporting.
Author
Owner

@doctrinebot commented on GitHub (Jun 7, 2010):

Comment created by romanb:

Thanks. This is fixed now.

@doctrinebot commented on GitHub (Jun 7, 2010): Comment created by romanb: Thanks. This is fixed now.
Author
Owner

@doctrinebot commented on GitHub (Jun 7, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jun 7, 2010): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#767