Skip to content

Fix a bug with entity Proxies

Choose a tag to compare

@alterphp alterphp released this 09 Nov 19:33
· 31 commits to master since this release
8141dd7
Fixes EmbedListHelper when the entity is a doctrine proxies (#189)

Under some circumstance, the entity could be a proxy.

This is due to a combinaison of different factors:

* The current admin screen (organization) is on a sub property of the
user
* The connected user / admin has relation or not the the organization
* Doctrine might lazy load admin's organization
* Doctrine has internal caches in UOW, and returns entity or proxy when
loaded

So sometime, The following method [1] returns an instance of
`AppBundle\Entity\Organization`, and sometimes an instance of
`Proxies\__CG__\AppBundle\Entity\Organization`.

Thanks to this patch, we always retrieves the correct information
metadata.

---

Oh, I forget to describe the original bug! When a proxy is returned, the
`EmbeddedListHelper` class could not find metadata. So it could not
filter the
sub list. So the admin screen displays all projetcs (not for the current
organization but of the whole application :D )

[1]
https://github.com/EasyCorp/EasyAdminBundle/blob/bb128e7f19b4ec419cccdf773292a1ec3ee31978/src/EventListener/RequestPostInitializeListener.php#L68