After upgrading from Symfony 6.1 to 7, I have had that error message :
AssertionError: assert($mapping instanceof ManyToManyOwningSideMapping)
We don’t have information about what part of the code makes this error pop. But we can see it must come from doctrine which has just been upgraded.
I tried to clear cache even though I already did it after the general upgrade, to see if the error stops showing up, but nothing came through.
2
Answers
I have found the solution!
I knew it was related to something outdated in my code, specifically with the doctrine attributes, but I got a quick answer here
To sum it up, try to comment/delete the JoinColumn or JoinTable attributes related to the many to many relations in your entities, it should work.
Hope it helps!
delete => #[ORMJoinColumn(nullable: true)]
In this example, Establishment has a ManyToMany relationship with EstablishmentAdd. The $establishmentAdds property is initialized as an ArrayCollection in the Establishment constructor. This means that even if no EstablishmentAdd entities are associated with Establishment, the $establishmentAdds property will be an empty collection instead of null.
Thus, while you can’t explicitly set nullable=true on a ManyToMany relationship, you can manage a "no relationship" state by allowing the collection to be empty. This approach is usually sufficient for most cases where nullable would be considered in relationships like OneToMany or ManyToOne.