1
0
mirror of synced 2025-02-22 07:03:13 +03:00

DDC-2704 - handling partial initialization of the class as expected (class metadata may not hold reflection class after wakeup)

This commit is contained in:
Marco Pivetta 2015-01-20 15:03:22 +01:00
parent 1e6c071bb8
commit a4982a8dc2

View File

@ -3347,20 +3347,24 @@ class ClassMetadataInfo implements ClassMetadata
*/ */
private function initializeAllReflectionProperties(ReflectionService $reflectionService) private function initializeAllReflectionProperties(ReflectionService $reflectionService)
{ {
$class = $this->reflClass; if (! $this->reflClass) {
return;
}
$currentClass = $this->reflClass;
$properties = array(); $properties = array();
do { do {
$className = $class->getName(); $className = $currentClass->getName();
foreach ($class->getProperties() as $property) { foreach ($currentClass->getProperties() as $property) {
// static properties are not instance properties // static properties are not instance properties
if ($property->isStatic()) { if ($property->isStatic()) {
continue; continue;
} }
// indexing by logical name to avoid duplicates // indexing by logical name to avoid duplicates
$logicalName = $property->getDeclaringClass()->getName() . $property->getName(); $logicalName = $property->getDeclaringClass()->getName() . '::' . $property->getName();
$propertyName = $property->getName(); $propertyName = $property->getName();
$existingField = isset($this->reflFields[$propertyName]) ? $this->reflFields[$propertyName] : null; $existingField = isset($this->reflFields[$propertyName]) ? $this->reflFields[$propertyName] : null;
@ -3382,8 +3386,8 @@ class ClassMetadataInfo implements ClassMetadata
$properties[$logicalName] = $existingField; $properties[$logicalName] = $existingField;
} }
$parentClass = $class->getParentClass(); $parentClass = $currentClass->getParentClass();
} while ($parentClass && $class = $reflectionService->getClass($parentClass->getName())); } while ($parentClass && $currentClass = $reflectionService->getClass($parentClass->getName()));
$this->reflectionProperties = array_values($properties); $this->reflectionProperties = array_values($properties);
} }