DDC-248: Exception is thrown during deserialization of the class 'ClassMetadata' if it contains child type #306

Closed
opened 2026-01-22 12:34:05 +01:00 by admin · 7 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 11, 2010).

Jira issue originally created by user cloun:

I have a class hierarchy:
resource (id, type, name)
|---> module ()
|---> controller (ref to module)
---> action (ref to controller)
It is mapped with inheritamce type = "JOINED"
During the class ClassMetadata deserialization exception belows is thrown:

ReflectionException: Property id does not exist in E:\Projects\portal\library\Doctrine\ORM\Mapping\ClassMetadata.php on line 362

Call Stack:
0.0003 334120 1. {main}() E:\Projects\DoctrineTest\index.php:0
0.0291 2124544 2. Doctrine\ORM\EntityManager->find() E:\Projects\DoctrineTest\index.php:24
0.0291 2124544 3. Doctrine\ORM\EntityManager->getRepository() E:\Projects\portal\library\Doctrine\ORM\EntityManager.php:308
0.0291 2124544 4. Doctrine\ORM\EntityManager->getClassMetadata() E:\Projects\portal\library\Doctrine\ORM\EntityManager.php:489
0.0291 2124544 5. Doctrine\ORM\Mapping\ClassMetadataFactory->getMetadataFor() E:\Projects\portal\library\Doctrine\ORM\EntityManager.php:220
0.0291 2124608 6. Doctrine\Common\Cache\AbstractCache->fetch() E:\Projects\portal\library\Doctrine\ORM\Mapping\ClassMetadataFactory.php:133
0.0292 2124608 7. CacheDriver->_doFetch() E:\Projects\portal\library\Doctrine\Common\Cache\AbstractCache.php:89
0.0292 2124608 8. CacheDriver->init() E:\Projects\DoctrineTest\CacheDriver.php:61
0.0293 2127872 9. unserialize() E:\Projects\DoctrineTest\CacheDriver.php:49
0.0336 2609432 10. Doctrine\ORM\Mapping\ClassMetadata->**wakeup() E:\Projects\portal\library\Doctrine\ORM\Mapping\ClassMetadata.php:0
0.0340 2633128 11. ReflectionClass->getProperty() E:\Projects\portal\library\Doctrine\ORM\Mapping\ClassMetadata.php:362
I have attached file with sample code.. I hope it will be helpful

Originally created by @doctrinebot on GitHub (Jan 11, 2010). Jira issue originally created by user cloun: I have a class hierarchy: resource (id, type, name) |---> module () |---> controller (ref to module) ---> action (ref to controller) It is mapped with inheritamce type = "JOINED" During the class ClassMetadata deserialization exception belows is thrown: ReflectionException: Property id does not exist in E:\Projects\portal\library\Doctrine\ORM\Mapping\ClassMetadata.php on line 362 Call Stack: 0.0003 334120 1. {main}() E:\Projects\DoctrineTest\index.php:0 0.0291 2124544 2. Doctrine\ORM\EntityManager->find() E:\Projects\DoctrineTest\index.php:24 0.0291 2124544 3. Doctrine\ORM\EntityManager->getRepository() E:\Projects\portal\library\Doctrine\ORM\EntityManager.php:308 0.0291 2124544 4. Doctrine\ORM\EntityManager->getClassMetadata() E:\Projects\portal\library\Doctrine\ORM\EntityManager.php:489 0.0291 2124544 5. Doctrine\ORM\Mapping\ClassMetadataFactory->getMetadataFor() E:\Projects\portal\library\Doctrine\ORM\EntityManager.php:220 0.0291 2124608 6. Doctrine\Common\Cache\AbstractCache->fetch() E:\Projects\portal\library\Doctrine\ORM\Mapping\ClassMetadataFactory.php:133 0.0292 2124608 7. CacheDriver->_doFetch() E:\Projects\portal\library\Doctrine\Common\Cache\AbstractCache.php:89 0.0292 2124608 8. CacheDriver->init() E:\Projects\DoctrineTest\CacheDriver.php:61 0.0293 2127872 9. unserialize() E:\Projects\DoctrineTest\CacheDriver.php:49 0.0336 2609432 10. Doctrine\ORM\Mapping\ClassMetadata->**wakeup() E:\Projects\portal\library\Doctrine\ORM\Mapping\ClassMetadata.php:0 0.0340 2633128 11. ReflectionClass->getProperty() E:\Projects\portal\library\Doctrine\ORM\Mapping\ClassMetadata.php:362 I have attached file with sample code.. I hope it will be helpful
admin added the Bug label 2026-01-22 12:34:05 +01:00
admin closed this issue 2026-01-22 12:34:06 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 11, 2010):

Comment created by cloun:

I have found workaround:

  1. add to returned by the *_sleep method array 'reflClass' and 'reflFields' fields.
  2. write code for recreating the ReflectionClass and ReflectionPropery objects (I think this is a PHP error, Reflection_ classes is restored in wrong state). It looks like code below:
        $this->reflClass = new \ReflectionClass($this->reflClass->name);
        foreach ($this->reflFields as $field => $reflField) {
            $this->reflFields[$field] = new \ReflectionProperty($reflField->class, $reflField->name);
            $this->reflFields[$field]->setAccessible(true);
        }
@doctrinebot commented on GitHub (Jan 11, 2010): Comment created by cloun: I have found workaround: 1. add to returned by the *_sleep method array 'reflClass' and 'reflFields' fields. 2. write code for recreating the ReflectionClass and ReflectionPropery objects (I think this is a PHP error, Reflection_ classes is restored in wrong state). It looks like code below: ``` $this->reflClass = new \ReflectionClass($this->reflClass->name); foreach ($this->reflFields as $field => $reflField) { $this->reflFields[$field] = new \ReflectionProperty($reflField->class, $reflField->name); $this->reflFields[$field]->setAccessible(true); } ```
Author
Owner

@doctrinebot commented on GitHub (Jan 11, 2010):

Comment created by cloun:

Sorry, but my workaround doesn't work =(

@doctrinebot commented on GitHub (Jan 11, 2010): Comment created by cloun: Sorry, but my workaround doesn't work =(
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2010):

Comment created by wb:

The issue seems to be that ReflectionClass::getProperty() will only return properties that are defined directly by the class. The attached patch seems to resolve the issue for me.

@doctrinebot commented on GitHub (Jan 15, 2010): Comment created by wb: The issue seems to be that ReflectionClass::getProperty() will only return properties that are defined directly by the class. The attached patch seems to resolve the issue for me.
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2010):

Comment created by romanb:

Thanks for the patch but I think there is a better (faster) way to resolve this as we know when a field stems from a superclass and the name of that class.

I will commit a patch soon.

@doctrinebot commented on GitHub (Jan 15, 2010): Comment created by romanb: Thanks for the patch but I think there is a better (faster) way to resolve this as we know when a field stems from a superclass and the name of that class. I will commit a patch soon.
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2010):

Comment created by romanb:

Should be fixed now.

@doctrinebot commented on GitHub (Jan 15, 2010): Comment created by romanb: Should be fixed now.
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jan 15, 2010): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/dc6614ca813b2c141e6b

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/dc6614ca813b2c141e6b - [10287_ClassMetadata.php.patch](https://gist.github.com/dc6614ca813b2c141e6b#file-10287_ClassMetadata-php-patch)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#306