DCOM-224: If @ManyToOne targetEntity contains class name with double slashes, "Cannot redeclare class" error is raised #531

Closed
doctrinebot opened this Issue Nov 30, 2013 · 10 comments

2 participants

@doctrinebot

Jira issue originally created by user vmattila:

If @ManyToOne (and apparently any other association annotation) contains targetEntity with "wrongly" defined fully qualified class name in format like My\Entity\Class, Fatal error "Cannot redeclare class" is raised when running command to generate schema.

It would be more intuitive (and save some debugging hours ;) if a proper exception of wrongly defined class name would be raised.

@doctrinebot

Comment created by cordoval:

i haven't tried annotations yet but in yml and on master this gives me:

[Doctrine\ORM\Mapping\MappingException]
The target-entity Acme\DemoBundle\Entity\UserX cannot be found in 'Acme\DemoBundle\Entity\Category#users
'.

let me try annotations ...

@doctrinebot

Comment created by cordoval:

yeah this should be pretty much closed @ocramius @beberlei

@doctrinebot

Comment created by @ocramius:

Copied comment from 2844:

The issue should try to create a mapping of the kind

@ManyToOne(targetEntity="Foo\\Bar")

explicitly using two backslashes in the namespace seperator and try if an error occurs. This might be autoloader and Operating System dependent. Even if there is no error, we should fix "Doctrine\ORM\Mapping\ClassMetadataInfo" to replace double backslashes everywhere with one backslash correctly. This affects targetEntity and DiscrimnatorMap.

@doctrinebot

Comment created by @ocramius:

I'd rather throw an exception to warn the user about the abuse of backslashes.

@doctrinebot

Comment created by @ocramius:

Moved to doctrine common, since it's an issue with how metadata is being loaded when referenced

@doctrinebot

Comment created by @ocramius:

Provided a hotfix at #309

@doctrinebot

Comment created by @doctrinebot:

A related Github Pull-Request [GH-309] was closed:
#309

@doctrinebot

Comment created by @ocramius:

After discussing this on #309, it turned out that we shouldn't fix incorrect backslash escaping in annotations.

@doctrinebot

Issue was closed with resolution "Won't Fix"

@Ocramius Ocramius was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment