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

Make sure unneeded fields are not present #10682

Merged
merged 1 commit into from
May 7, 2023

Conversation

greg0ire
Copy link
Member

@greg0ire greg0ire commented May 5, 2023

Instead of ensuring every mapping array has a mappedBy and an inversedBy field, let us do the opposite, and remove them when they are null. Likewise if there is a joinColumns field, it is useless if null or empty.

Found while working on #10681
These unneeded fields make the work unnecessarily hard.

Instead of ensuring every mapping array has a mappedBy and an inversedBy
field, let us do the opposite, and remove them when they are null.
Likewise if there is a joinColumns field, it is useless if null or
empty.
Copy link
Member

@SenseException SenseException left a comment

Choose a reason for hiding this comment

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

Why removing the array elements in ClassMetadataBuilderTest when they don't have an impact in _validateAndCompleteAssociationMapping anymore?

@greg0ire
Copy link
Member Author

greg0ire commented May 7, 2023

The array elements in that tests are compare used to build DTOs that we compare to other DTO built thanks to this class, which no longer includes them now. Wait no that's not it… I don't remember why I did this 🤔

Maybe that's something I did before extracting this to a separate commit 🤔

Ah yes that's it! When I use git restore --source=origin/3.0.x tests/Doctrine/Tests/ORM/Mapping/ClassMetadataBuilderTest.php on the branch from #10681 , then the tests fail. The new, reworked hierarchy understands this is not normal:

OutOfRangeException: Unknown property mappedBy on class Doctrine\ORM\Mapping\ManyToOneAssociationMapping

That's what forced me to do this change, but this is the correct thing to do IMO, regardless of whether the test suite passes or not.

@greg0ire greg0ire merged commit a9c80c2 into doctrine:3.0.x May 7, 2023
@greg0ire greg0ire deleted the remove-unneeded-fields branch May 7, 2023 21:48
@greg0ire greg0ire added this to the 3.0.0 milestone May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants