From 53e8b8f32dddc854a75709ad128b2aebc398ca41 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Tue, 9 Nov 2010 22:13:35 +0100 Subject: [PATCH] DDC-868 - Fix bug where a ClassMetadata instance from a STI child level is processed before the parent. --- lib/Doctrine/ORM/Tools/SchemaTool.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php index d201d1829..cee2fe294 100644 --- a/lib/Doctrine/ORM/Tools/SchemaTool.php +++ b/lib/Doctrine/ORM/Tools/SchemaTool.php @@ -92,6 +92,22 @@ class SchemaTool return $schema->toSql($this->_platform); } + /** + * Some instances of ClassMetadata don't need to be processed in the SchemaTool context. This method detects them. + * + * @param ClassMetadata $class + * @param array $processedClasses + * @return bool + */ + private function processingNotRequired($class, array $processedClasses) + { + return ( + isset($processedClasses[$class->name]) || + $class->isMappedSuperclass || + ($class->isInheritanceTypeSingleTable() && $class->name != $class->rootEntityName) + ); + } + /** * From a given set of metadata classes this method creates a Schema instance. * @@ -110,7 +126,7 @@ class SchemaTool $evm = $this->_em->getEventManager(); foreach ($classes as $class) { - if (isset($processedClasses[$class->name]) || $class->isMappedSuperclass) { + if ($this->processingNotRequired($class, $processedClasses)) { continue; }