Skip to content

Loading…

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

Closed
doctrinebot opened this Issue · 7 comments

1 participant

@doctrinebot

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

@doctrinebot

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

Comment created by cloun:

Sorry, but my workaround doesn't work =(

@doctrinebot

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

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

Comment created by romanb:

Should be fixed now.

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added this to the 2.0-ALPHA4 milestone
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.