You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem occurs when overloading entities multiple times. For example, we create a new entity Base\User, which inherits from Sulu\User. We override the email column in the .orm mapping using XML with the <attribute-override> attribute. Then we create another entity App\User, which inherits from Base/User:
<?php
declare(strict_types=1);
namespace App;
class User extends \Base\User
{
}
<?php
declare(strict_types=1);
namespace Base;
class User extends \Sulu\Bundle\SecurityBundle\Entity\User
{
}
Upon running doctrine:scheme:validate, we encounter the error "Invalid field override named 'email' for class 'Base\User'". The issue arises in the class Sulu\Component\Persistence\EventSubscriber\ORM\MetadataSubscriber, which takes parents (Base\User then Sulu\User) from App\User and sets metadata for App\User associations. The error occurs at line 105: $configuration->getMetadataDriverImpl()->loadMetadataForClass($parent, $parentMetadata);, during the initialization of metadata for Base\User (in the loadMetadataForClass method) because it does not consider that the entity may have its own parents.
Expected Behavior + Possible Solutions
The expected behavior is that the method should initialize metadata for all parent entities and gradually set it for all children. A correct implementation can be found, for example, in the Doctrine\Persistence\Mapping\AbstractClassMetadataFactory class in the getAllMetadata() method.
The text was updated successfully, but these errors were encountered:
bober888
added
the
Bug
Error or unexpected behavior of already existing functionality
label
Apr 30, 2024
We don't have yet any experience with using a mapped super class between of them or using attribute-override, but think it should be possible with some refactoring. I remeber that we used a normaly entity in between with them adding new properties where there no problem.
Still I want to mention that we can never guarante backwards compatibility for models which are changed via attribute-override, this may can crash if Sulu depends on some cases like this attribute being unique or a specific length for an index.
If you want to contribute a patch, give it a try, but it will require some special test setup so we can guarantee it will work in future.
Actual Behavior + Steps to Reproduce
The problem occurs when overloading entities multiple times. For example, we create a new entity
Base\User
, which inherits fromSulu\User
. We override the email column in the.orm
mapping using XML with the<attribute-override>
attribute. Then we create another entityApp\User
, which inherits fromBase/User
:Base\User mapping:
Upon running
doctrine:scheme:validate
, we encounter the error "Invalid field override named 'email' for class 'Base\User'". The issue arises in the classSulu\Component\Persistence\EventSubscriber\ORM\MetadataSubscriber
, which takes parents (Base\User
thenSulu\User
) fromApp\User
and sets metadata forApp\User
associations. The error occurs at line 105:$configuration->getMetadataDriverImpl()->loadMetadataForClass($parent, $parentMetadata);
, during the initialization of metadata for Base\User (in theloadMetadataForClass
method) because it does not consider that the entity may have its own parents.Expected Behavior + Possible Solutions
The expected behavior is that the method should initialize metadata for all parent entities and gradually set it for all children. A correct implementation can be found, for example, in the
Doctrine\Persistence\Mapping\AbstractClassMetadataFactory
class in thegetAllMetadata()
method.The text was updated successfully, but these errors were encountered: