mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-115: Two ClassMetadata instances for an entity in global namespace #145
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Nov 4, 2009).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user @beberlei:
The global namespace creates problems for entities that are retrieved via getClassMetadata($className) when $className is not prepended by "". This is only a problem in the global namespace, because in other instances a slash might be present and the metadata factory does not find the relevant previously generated ClassMetadata instance.
This problem specifically occours with Annotations Mapping, since ReflectionClass::getName() returns the class name unqualified.
I attached a Test-Case that proves this behaviour. It requires the additional attached Global namespace model data.
@doctrinebot commented on GitHub (Nov 4, 2009):
Comment created by @beberlei:
@doctrinebot commented on GitHub (Nov 4, 2009):
Comment created by @beberlei:
Committing a patch that adds the following snippet:
to each of the following methods of ClassMetadataFactory:
@doctrinebot commented on GitHub (Nov 4, 2009):
Comment created by @beberlei:
Applied to trunk, Can someone verify this is ok?
@doctrinebot commented on GitHub (Nov 4, 2009):
Issue was closed with resolution "Fixed"
@doctrinebot commented on GitHub (Nov 4, 2009):
Comment created by romanb:
Not sure I understand this. As I said in another issue class names in strings are always considered fully qualified by php. A leading backslash in class names in strings should never be used it is completely unnecessary.
The patch is problematic because the methods they're applied to are one of the most-called methods and they were already "slow enough" previously.
If there is a problem and the problem is only with models in the global namespace then this should not be fixed. User-defined classes dont belong in the global namespace, ever.
@doctrinebot commented on GitHub (Nov 4, 2009):
Comment created by @beberlei:
We found the true issue.
Several methods in ClassMetadataInfo assumed when no slash was prepended that a shortcut is used and prepends its own namespace plus a NS. This caused the problem which is now fixed by additionally checking for strlen($this->namespace) on this positions.
@doctrinebot commented on GitHub (Dec 13, 2015):
Imported 2 attachments from Jira into https://gist.github.com/dc80c18ef0726240bcad