DDC-868: ORM:Schema-tool:create failure -- the result depends on xml files enumeration order of RecursiveDirectoryIterator in context of SINGLE_TABLE inherantence #1077

Closed
opened 2026-01-22 13:01:07 +01:00 by admin · 4 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 8, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user xhorse:

= Relevant configuration: =
resources.doctrine.driver.class = Doctrine\ORM\Mapping\Driver\XmlDriver
resources.doctrine.driver.dir = APPLICATION_PATH "/../library/Droop/Model/Xml"
resources.doctrine.cache.class = Doctrine\Common\Cache\ArrayCache
resources.doctrine.conn.driver = pdo_mysql

= Models hierarchy =
class Sysbase {}
class Drooplet extends Sysbase {}
class Menu extends Sysbase {}

= Xml driver =
attached

= Error =
While using command line to generate schema [php doctrine.php orm:schema-tool:create --dump-sql], it reports error "The table with name 'system' already exists." on windows however not on linux.

It is because the ClassMetaFactory.php depends on the sequence of result returned by getAllClassNames(). In this scenario, it's in descending order on linux and ascending on windows.
124 foreach ($this->driver->getAllClassNames() as $className) {
125 $metadata[] = $this->getMetadataFor($className);
126 }
127
128 return $metadata;
This order populates to SchemaTool::getSchemaFromMetadata(); If the base model is processed before it's descendants, everything is OK. Otherwise, it will complain about the table already exists.

= Fix =
ClassMetaFactory.php
128 return $this->loadedMetadata;

Originally created by @doctrinebot on GitHub (Nov 8, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user xhorse: = Relevant configuration: = resources.doctrine.driver.class = Doctrine\ORM\Mapping\Driver\XmlDriver resources.doctrine.driver.dir = APPLICATION_PATH "/../library/Droop/Model/Xml" resources.doctrine.cache.class = Doctrine\Common\Cache\ArrayCache resources.doctrine.conn.driver = pdo_mysql = Models hierarchy = class Sysbase {} class Drooplet extends Sysbase {} class Menu extends Sysbase {} = Xml driver = attached = Error = While using command line to generate schema [php doctrine.php orm:schema-tool:create --dump-sql], it reports error "The table with name 'system' already exists." on windows however not on linux. It is because the ClassMetaFactory.php depends on the sequence of result returned by getAllClassNames(). In this scenario, it's in descending order on linux and ascending on windows. 124 foreach ($this->driver->getAllClassNames() as $className) { 125 $metadata[] = $this->getMetadataFor($className); 126 } 127 128 return $metadata; This order populates to SchemaTool::getSchemaFromMetadata(); If the base model is processed before it's descendants, everything is OK. Otherwise, it will complain about the table already exists. = Fix = ClassMetaFactory.php 128 return $this->loadedMetadata;
admin added the Bug label 2026-01-22 13:01:07 +01:00
admin closed this issue 2026-01-22 13:01:08 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 9, 2010):

Comment created by @beberlei:

By what means is that a valid fix? Doesnt that just give another random order that happens to work for your cases now?

@doctrinebot commented on GitHub (Nov 9, 2010): Comment created by @beberlei: By what means is that a valid fix? Doesnt that just give another random order that happens to work for your cases now?
Author
Owner

@doctrinebot commented on GitHub (Nov 9, 2010):

Comment created by @beberlei:

Fixed

@doctrinebot commented on GitHub (Nov 9, 2010): Comment created by @beberlei: Fixed
Author
Owner

@doctrinebot commented on GitHub (Nov 9, 2010):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Nov 9, 2010): Issue was closed with resolution "Fixed"
Author
Owner
@doctrinebot commented on GitHub (Dec 13, 2015): Imported 3 attachments from Jira into https://gist.github.com/268603dcd05c7873ae21 - [10852_Droop.Model.Sysbase.dcm.xml](https://gist.github.com/268603dcd05c7873ae21#file-10852_Droop-Model-Sysbase-dcm-xml) - [10853_Droop.Model.Drooplet.dcm.xml](https://gist.github.com/268603dcd05c7873ae21#file-10853_Droop-Model-Drooplet-dcm-xml) - [10854_Droop.Model.Menu.dcm.xml](https://gist.github.com/268603dcd05c7873ae21#file-10854_Droop-Model-Menu-dcm-xml)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1077