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
Description
When we are using a function like public function addSomething() and no property with name: something not existing the exception "The entity has no field with name ..." is thrown.
How to reproduce
Create an entity with function addSomething() without property something and enable the auto mapping for validation.
Today I updated Symfony 4.2 to 4.3 and now I can't save entities that implement Interfaces or use traits, Mapping/PropertyMetadata class try to find a property in a interface and throw an error, my code snippet:
//When I try to save MyEntity throw an exception:...$entity = newMyEntity();
$em->persist($entity);
$em->flush();
...
Property "title" does not exist in class "GetterIdInterface"
Symfony\Component\Validator\Exception\ValidatorException in vendor/symfony/validator/Mapping/PropertyMetadata.php (line 40)
/* @throws ValidatorException */
public function __construct(string $class, string $name)
{
if (!property_exists($class, $name)) {
throw new ValidatorException(sprintf('Property "%s" does not exist in class "%s"', $name, $class));
}
parent::__construct($class, $name, $name);
}
I don't know if it's exactly the same, because I can save all my entities if they not implement an Interface o use Traits...
At the end maybe is the same issue.
I copy and paste here for clarity and more context, my (closed) issue (#31873):
Symfony version(s) affected: 4.3.0
Description
In one of my forms I receive this error:
Property "domain" does not exist in class "App\Entity\MyEntity"
Obviously it doesn't exist as the property is actually $domains.
So I have a method addDomain and a method removeDomain.
The problem is caused by the validation auto_mapping: if I disable it, the problem disappears
framework:
validation:
email_validation_mode: html5# Enables validator auto-mapping support.# For instance, basic validation constraints will be inferred from Doctrine's metadata.#auto_mapping:# App\Entity\: []
The PropertyInfo causes a lot of troubles: it tries to guess properties starting from methods: this causes a lot of strange behaviors. Not strictly related to this, this is another example: php-translation/symfony-bundle#309
Activity
cronk1986 commentedon Jun 2, 2019
Today I updated Symfony 4.2 to 4.3 and now I can't save entities that implement Interfaces or use traits, Mapping/PropertyMetadata class try to find a property in a interface and throw an error, my code snippet:
any idea?
linaori commentedon Jun 3, 2019
Is this issue related to #31715?
cronk1986 commentedon Jun 3, 2019
I don't know if it's exactly the same, because I can save all my entities if they not implement an Interface o use Traits...
At the end maybe is the same issue.
Aerendir commentedon Jun 5, 2019
I copy and paste here for clarity and more context, my (closed) issue (#31873):
Symfony version(s) affected: 4.3.0
Description
In one of my forms I receive this error:
Obviously it doesn't exist as the property is actually
$domains
.So I have a method
addDomain
and a methodremoveDomain
.The problem is caused by the validation
auto_mapping
: if I disable it, the problem disappearsThe
PropertyInfo
causes a lot of troubles: it tries to guess properties starting from methods: this causes a lot of strange behaviors. Not strictly related to this, this is another example: php-translation/symfony-bundle#309weaverryan commentedon Jun 7, 2019
I can confirm this, here is a simple reproducer: https://github.com/weaverryan/symfony-automapper-reproducer - you can see the simple steps in the history:
src/Entity
without a corresponding property/
in the reproducer):bug #31936 PropertyInfoLoader should not try to add validation to non…
cronk1986 commentedon Jun 8, 2019
Perfect, now works!
Thank you!