Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document class is unlisted in the discriminator map - using no discriminator map #2002

Closed
josefsabl opened this issue Apr 10, 2019 · 6 comments
Assignees
Milestone

Comments

@josefsabl
Copy link
Contributor

Bug Report

Q A
BC Break yes
Version 2.0.0-beta2

Summary

Document class "Domain\XYZ\Document" is unlisted in the discriminator map although I am using no discriminator map.

Possibly related to this: #867

Current behavior

Let's assume this code:

/**
 * @ODM\Document()
 * @ODM\InheritanceType("SINGLE_COLLECTION")
 * @ODM\DiscriminatorField("class")
 */
class DocumentA {
    /**
     * @ODM\ReferenceOne(targetDocument="DocumentA")
     * @ODM\Index
     * @var Document|null
     */
    public $parentDocument;
}

/**
 * @ODM\Document()
 */
class DocumentB extends DocumentA {
}

$docB = new DocumentB;
$docB->parentDocument = $docA;

Now I get the Document class "DocumentA" is unlisted in the discriminator map exception on a flush.

The interesting fact is that when I create the $docA in the same script as the $docB everything works.

However when I load it from the database prior setting it to the property, I get the exception.

@alcaeus
Copy link
Member

alcaeus commented Apr 11, 2019

Could you by any chance reproduce this in a test case? You can find a whole bunch of such test cases in https://github.com/doctrine/mongodb-odm/tree/master/tests/Doctrine/ODM/MongoDB/Tests/Functional/Ticket. Thanks!

@josefsabl
Copy link
Contributor Author

Will give it a shot.

@josefsabl
Copy link
Contributor Author

Done. I hope the clearing loaded metadata like that is okay. It simulates my problem where request that doesn't work with document A but works with document B fails.

@josefsabl
Copy link
Contributor Author

josefsabl commented Apr 16, 2019

Until the bug is fixed, I forked the ODM and just plainly disabled the exception whatsoever to enable me to work on my project.

@alcaeus
Copy link
Member

alcaeus commented Apr 28, 2019

Fix has been merged to 1.3 and master. Thanks for reporting, and more so for the failing test case!

@josefsabl
Copy link
Contributor Author

The exception went away, but a new problem appeared. See: #2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants