New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't fail if the cached type is not ClassMetadata #717
Conversation
This is a random error and I didn't found yet how to reproduce it. It may related with Zend OPCache as usuallly is thrown while hot deploy new versions PHP Fatal error: Uncaught TypeError: Argument 1 passed to Doctrine\\ORM\\Mapping\\ClassMetadataFactory::wakeupReflection() must implement interface Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata, array given, called in /v2/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php on line 214 and defined in /v2/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php:718 Stack trace: #0 /v2/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(214): Doctrine\\ORM\\Mapping\\ClassMetadataFactory->wakeupReflection(Array, Object(Doctrine\\Common\\Persistence\\Mapping\\RuntimeReflectionService)) doctrine#1 /v2/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(281): Doctrine\\Common\\Persistence\\Mapping\\AbstractClassMetadataFactory->getMetadataFor('Model\\\\...') doctrine#2 /v2/vendor/doctrine/orm/lib/Doctrine/ORM/Repository/DefaultRepositoryFactory.php(44): Doctrine\\ORM\\EntityManager->getClassMetadata('Model\\\\...') doctrine#3 /v2/vendor/doctrine/orm/ in /v2/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php on line 718
Well, the question is why you have an array here ? your cache is corrupted |
Regardless of that, the cache layer provides no guarantees, so we are doing something wrong on our side too. |
@Ocramius but then, if you want to account for corrupted cache, you would also need to validate that the metadata retrieved from the cache are for the right class, and so on. |
Good point. Yes, fixing that is non-trivial
|
Just one thing: Cache issues shouldn't be a reason because the application returns a HTTP 500 error (like a TypeError do). When Memcache server is not available the application does not blow up, just work like if cache is not available. Two scenarios where I saw this error (environment: VM with Ubuntu 16.04 -fresh installation- Memcache installed)
|
I was able to capture the values involved in the error var_dump($realClassName);
string(19) "AcmeCore\Model\User"
var_dump($this->cacheSalt);
string(14) "$CLASSMETADATA"
var_dump($cached);
array(7) {
["Doctrine\ORM\Mapping\Entity"]=>
object(Doctrine\ORM\Mapping\Entity)#308 (2) {
["repositoryClass"]=>
string(14) "UserRepository"
["readOnly"]=>
bool(false)
}
["Doctrine\ORM\Mapping\EntityListeners"]=>
object(Doctrine\ORM\Mapping\EntityListeners)#309 (1) {
["value"]=>
array(1) {
[0]=>
string(12) "UserListener"
}
}
["Doctrine\ORM\Mapping\InheritanceType"]=>
object(Doctrine\ORM\Mapping\InheritanceType)#310 (1) {
["value"]=>
string(12) "SINGLE_TABLE"
}
["Doctrine\ORM\Mapping\DiscriminatorColumn"]=>
object(Doctrine\ORM\Mapping\DiscriminatorColumn)#311 (5) {
["name"]=>
string(4) "type"
["type"]=>
string(6) "string"
["length"]=>
NULL
["fieldName"]=>
NULL
["columnDefinition"]=>
NULL
}
["Doctrine\ORM\Mapping\DiscriminatorMap"]=>
object(Doctrine\ORM\Mapping\DiscriminatorMap)#312 (1) {
["value"]=>
array(2) {
["user"]=>
string(4) "User"
["enterprise"]=>
string(10) "Enterprise"
}
}
["Doctrine\ORM\Mapping\Table"]=>
object(Doctrine\ORM\Mapping\Table)#313 (5) {
["name"]=>
string(4) "User"
["schema"]=>
NULL
["indexes"]=>
array(1) {
[0]=>
object(Doctrine\ORM\Mapping\Index)#314 (4) {
["name"]=>
string(11) "User_status"
["columns"]=>
array(1) {
[0]=>
string(6) "status"
}
["flags"]=>
NULL
["options"]=>
NULL
}
}
["uniqueConstraints"]=>
array(1) {
[0]=>
object(Doctrine\ORM\Mapping\UniqueConstraint)#315 (3) {
["name"]=>
string(10) "User_email"
["columns"]=>
array(1) {
[0]=>
string(5) "email"
}
["options"]=>
NULL
}
}
["options"]=>
array(0) {
}
}
["Doctrine\ORM\Mapping\HasLifecycleCallbacks"]=>
object(Doctrine\ORM\Mapping\HasLifecycleCallbacks)#316 (0) {
}
} This is the metadata associated to User entity /**
* @ORM\Entity(repositoryClass="UserRepository")
* @ORM\EntityListeners({"UserListener"})
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="type", type="string")
* @ORM\DiscriminatorMap({"user" = "User", "enterprise" = "Enterprise"})
* @ORM\Table(
* name="User",
* uniqueConstraints={@ORM\UniqueConstraint(name="User_email", columns={"email"})},
* indexes={@ORM\index(name="User_status", columns={"status"})}
* )
* @ORM\HasLifecycleCallbacks()
*/ This one is the Enterprise entity /**
* @ORM\Entity(repositoryClass="UserRepository")
*/ |
Environment Ubuntu 16.04
|
…data-2.6' into 2.6 Backport #717 to 2.6.x
This is a random error and I didn't found yet how to reproduce it. It may related with Zend OPCache as usuallly is thrown while hot deploy new versions