Skip to content

Fix the EntityRegenerator on Mac #179

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

Merged
merged 2 commits into from
May 11, 2018

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented May 11, 2018

On Mac, an instance of Doctrine\Common\Persistence\Mapping\MappingException is thrown by Doctrine when a mapping file references a non-existing class. Currently, the code only catches Doctrine\ORM\Mapping\MappingException instances.

This PR makes the tests green on Mac (#167 (comment)). This also probably fixes a real bug.

I've no idea why Doctrine throws a different exception on Mac than on Linux.

@dunglas dunglas requested a review from weaverryan May 11, 2018 05:12
@@ -43,7 +44,7 @@ public function regenerateEntities(string $classOrNamespace)
{
try {
$metadata = $this->doctrineHelper->getMetadata($classOrNamespace);
} catch (MappingException $mappingException) {
} catch (MappingException | CommonMappingException $mappingException) {
Copy link
Member Author

@dunglas dunglas May 11, 2018

Choose a reason for hiding this comment

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

Excluding this file on PHP 7 makes Travis happy!

This cause PHP CS Fixer's linting to fail on PHP 7 because this syntax is supported only since PHP 7.1. However the make:entity command already requires 7.1.
Do you want me to use multiple catch blocks or just to ignore this file in the PHP CS config on PHP 7?

@andrewtch
Copy link
Contributor

The exception | exception syntax is not supported in php 7.0 (and the bundle does support it).

@dunglas
Copy link
Member Author

dunglas commented May 11, 2018

@andrewtch
Copy link
Contributor

@dunglas , ah, indeed. The current fix seems to work for me just fine.

@weaverryan
Copy link
Member

Fantastic! Super weird, but the code/fix gives us code that still makes sense: if there’s a mapping exception in general, fallback to the disconnected metadata lookup.

Hopefully this will unblock some things!

@weaverryan weaverryan merged commit 951dbff into symfony:master May 11, 2018
@dunglas dunglas deleted the fix-entity-regenerator-test branch May 11, 2018 19:14
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.

3 participants