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

Fix Entity directory does not exist #311

Merged
merged 3 commits into from
Dec 20, 2018

Conversation

yceruto
Copy link
Member

@yceruto yceruto commented Oct 29, 2018

Closes #299 according to #185 (comment)

Also alternative for #185, #265 and #310

@weaverryan
Copy link
Member

OMG - finally! So happy to see this PR! And, it was even simpler than I expected!

We do have test failures, unfortunately. @yceruto could you take a look at them? They could be false failures. But it might also be an indication that using the new way may cause an unintended exception to be thrown in some cases.

Thanks!

@weaverryan
Copy link
Member

Also, see #310 - I think the other PR may have "hit" the same issue that's causing the tests to fail here 🤔

@yceruto
Copy link
Member Author

yceruto commented Nov 3, 2018

Yep, (in the same life time of the script) the first time that $this->doctrineHelper->getEntitiesForAutocomplete() -> $cmf->getAllMetadata() is called with no entities some protected Doctrine properties are cached (e.g. AnnotationDriver::$classNames) and there is no way to invalidate it without force it and discover the metadatas of the new generated Entity.

Even if the last commit resolves part of the problem I guess there are still other cached properties related to the mapping type that need to be invalidated for the same reason.

So I think we should go back to the Finder version and use AnnotationDriver::getPaths() to discover the mapping Entity directory, wdyt?

@yceruto
Copy link
Member Author

yceruto commented Nov 3, 2018

Also we could re-think the way this Annotation Mapping requirement is validated, because currently it's checked after the entity was already generated.

@yceruto
Copy link
Member Author

yceruto commented Nov 5, 2018

Well, I've fixed an invalid mapping from the fixture of the two remaining fails and all green again.

$metadataDriver = $em->getConfiguration()->getMetadataDriverImpl();
if ($metadataDriver instanceof MappingDriverChain) {
foreach ($metadataDriver->getDrivers() as $driver) {
if ($driver instanceof AnnotationDriver) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! Yea, this issue is a bummer - but nice job at least finding a workaround.

Does this only affect the AnnotationDriver?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also for StaticPHPDriver but we only support annotation driver, right?

@weaverryan weaverryan merged commit 5f37c5d into symfony:master Dec 20, 2018
weaverryan added a commit that referenced this pull request Dec 20, 2018
This PR was squashed before being merged into the 1.0-dev branch (closes #311).

Discussion
----------

Fix Entity directory does not exist

Closes #299 according to #185 (comment)

Also alternative for #185, #265 and #310

Commits
-------

5f37c5d Remove invalid field mapping
06f5399 Invalidating cached AnnotationDriver::$classNames to find new entities
8b7c291 Fix 'src/Entity' directory does not exist
@weaverryan
Copy link
Member

Thank you very much for figuring this out @yceruto!

@yceruto yceruto deleted the fix_autocomplete_entities branch December 20, 2018 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants