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

Preserve existing class metadata #197

Merged
merged 1 commit into from
Jun 13, 2018
Merged

Preserve existing class metadata #197

merged 1 commit into from
Jun 13, 2018

Conversation

ro0NL
Copy link
Contributor

@ro0NL ro0NL commented Jun 3, 2018

Hi,

Im facing an issue related to make:entity. I noticed it uses DisconnectedClassMetadataFactory which at this point basically forgets about existing metadata (metadata that on itself is loaded during the loadClassMetadata event).

Real life example is e.g. https://github.com/msgphp/symfony-demo-app/blob/b9536243f4a0803b36acfef839ac0c3559a91bd6/src/Entity/User/UserRole.php#L11 where the roles field is mapped during loadClassMetadata.

Currently its mapping is not loaded, causing an invalid field override here.

This solves it.

@weaverryan
Copy link
Member

Hey @ro0NL!

We load the disconnected metadata factory when/because we can’t use the normal metadata factory, usually (entirely?) when we’re readijg metadata for an entity whose class doesn’t yet exist (so the normal metadata factory throws an error). Won’t using the metadata factory here trigger that error? It looks like the tests may be failing due to this.

@ro0NL
Copy link
Contributor Author

ro0NL commented Jun 3, 2018

after submitting the PR i realized a call to $em->getMetadataFactory()->getAllMetadata() is probably unintended in disconnected state. Now reverted as such to see if test pass

The current approach (try/catching) works for me.

@weaverryan
Copy link
Member

Very interesting - nice work. Thank you @ro0NL!

@weaverryan weaverryan merged commit 79ba86a into symfony:master Jun 13, 2018
weaverryan added a commit that referenced this pull request Jun 13, 2018
This PR was squashed before being merged into the 1.0-dev branch (closes #197).

Discussion
----------

Preserve existing class metadata

Hi,

Im facing an issue related to `make:entity`. I noticed it uses `DisconnectedClassMetadataFactory` which at this point basically forgets about existing metadata (metadata that on itself is loaded during the `loadClassMetadata` event).

Real life example is e.g. https://github.com/msgphp/symfony-demo-app/blob/b9536243f4a0803b36acfef839ac0c3559a91bd6/src/Entity/User/UserRole.php#L11 where the `roles` field is mapped during `loadClassMetadata`.

Currently its mapping is not loaded, causing an invalid field override here.

This solves it.

Commits
-------

79ba86a Preserve existing class metadata
@ro0NL ro0NL deleted the patch-1 branch June 27, 2018 08:12
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