0

Our stack is PHP 8.1, Symfony 6.1 and EasyAdmin 4.4, the context of the error is we are trying to edit an entity record through normal EA CRUD edit, the error when I try to edit the record is:

15:41:19.128 critical   Uncaught PHP Exception ErrorException: "User Notice: Undefined property: Proxies\__CG__\App\Entity\Sys\Auth\RoleClass::$ea_form_panel_01GKPKZ6CGWJ4FX3Q4J5C6C961" at /opt/app/var/cache/dev/doctrine/orm/Proxies/__CG__AppEntitySysAuthRoleClass.php line 101
request Show context Hide trace
{▼
  /opt/app/var/cache/dev/doctrine/orm/Proxies/__CG__AppEntitySysAuthRoleClass.php:101 {▶}
  /opt/app/vendor/symfony/property-access/PropertyAccessor.php:426 {▶}
  /opt/app/vendor/symfony/property-access/PropertyAccessor.php:115 {▶}
  /opt/app/vendor/easycorp/easyadmin-bundle/src/Field/Configurator/CommonPreConfigurator.php:47 {▶}
  /opt/app/vendor/easycorp/easyadmin-bundle/src/Factory/FieldFactory.php:100 {▶}
  /opt/app/vendor/easycorp/easyadmin-bundle/src/Factory/EntityFactory.php:43 {▶}
  /opt/app/vendor/easycorp/easyadmin-bundle/src/Controller/AbstractCrudController.php:218 {▶}
  /opt/app/vendor/symfony/http-kernel/HttpKernel.php:163 {▶}
  /opt/app/vendor/symfony/http-kernel/HttpKernel.php:75 {▶}
  /opt/app/vendor/symfony/http-kernel/Kernel.php:202 {▶}
  /opt/app/public/index.php:30 {▶}
}

What appears to be happening is the following:

  1. The Fields returned from configureFields() (in edit page mode) include Panel Fields

  2. The entity instance is a Proxy and not a 'real class'. I can't replicate this anywhere else, in all other cases (i.e. all edit views on all other entities I see a 'real class' and not a Proxy), in fact this error only occurs on specific instances of this entity type, most are fine, just 1 record causes this issue

  3. Since the entity instance is a Doctrine Proxy, the PropertyAccessor.php works differently because $this->getReadInfo($class, $property); treats Proxies differently as they have magic __get functions (it seems to assume that the property exists in ReflectionExtractor.getReadInfo on line 293 (I'm clearly missing something):

        if ($allowMagicGet && $reflClass->hasMethod('__get') && ($reflClass->getMethod('__get')->getModifiers() & $this->methodReflectionFlags)) {
            return new PropertyReadInfo(PropertyReadInfo::TYPE_PROPERTY, $property, PropertyReadInfo::VISIBILITY_PUBLIC, false, false);
        }

I am completely stumped as to why $context->getEntity()->getInstance() in AbstractCrudController::edit is returning a Doctrine Proxy in this very specific case (I've never seen this happen before). Tracing the code it feels that this should never be a Proxy (or you can't use Fields that don't exist on the Entity like Panels and Tabs).

0 Answers0