-
Notifications
You must be signed in to change notification settings - Fork 98
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
Guard against crashes when only an entity's interface is known #155
base: 1.3.x
Are you sure you want to change the base?
Conversation
This prevents a call to Doctrine's metadata factory with an interface, which throws an exception since the class in question is not an entity.
Hi,
|
Here's the stack trace:
I'll try to reproduce in a test. |
I've added test cases which reproduce the original issue, which was slightly different from what I originally thought - the example in The issue was analyzing a repository of an unknown concrete class which implements a known interface, which works just fine at runtime but relies somewhat on convention (and perhaps the implied availability of column mapping from presence of getters or setters) rather than being provably correct via Unfortunately this implementation does mean there's some unknown state, which arguably could be a warning, but that's still better than outright crashing. |
This should be addressed by my PR in #141, right? |
Unfortunately, it does not: I applied your patch to my working copy where I first encountered the issue, and the crash persists. When I add some basic debugging output to your code, I never even reach the change you made - even when combining both patches. Something as simple as I think our patches are solving slightly different (though both valid) issues. |
b2b2414
to
1fe21ab
Compare
aa4e98e
to
8b28264
Compare
I got a "please report this stack trace" error immediately following the extended configuration of this extension.
After a bit of digging while writing up the issue, including recovering a truncated stack trace, I found that this extension was trying to call
$objectManager->getClassMetadata()
with one of the interfaces that one of my entities implements, and Doctrine doesn't much care for you doing that. This change checks whether the class referenced is actually an interface and filters out further analysis since it a) crashes and b) isn't relevant for determining which fields are present on a Doctrine entity.This is a summary of the class hierarchy that triggered the error, though of course each interface and class is in its own autoloadable file:
While by the look of the stack trace it's some sort of Doctrine-generated issue, it seems like the debug output is being truncated.