Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DoctrineBridge] issues with UniqueEntityValidator on 7.1-RC1 #57075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmaicher opened this issue May 23, 2024 · 5 comments
Closed

[DoctrineBridge] issues with UniqueEntityValidator on 7.1-RC1 #57075

dmaicher opened this issue May 23, 2024 · 5 comments

Comments

@dmaicher
Copy link
Contributor

dmaicher commented May 23, 2024

Symfony version(s) affected

7.1 RC1

Description

I just tested 7.1 RC1 on my biggest app and I noticed this error:

ReflectionException:
Property Proxies\__CG__\CA\Core\UserBundle\Entity\User::$email does not exist

  at vendor/symfony/doctrine-bridge/Validator/Constraints/UniqueEntityValidator.php:298

How to reproduce

Unfortunately I cannot reproduce this issue yet on a smaller app like symfony-demo. Still looking into it 😕
See #57075 (comment)

Possible Solution

use PropertyAccessor to get the value here?

Additional Context

Downgrading DoctrineBridge and PropertyInfo to 7.0.7 solves the issue for me.

@dmaicher
Copy link
Contributor Author

Ok I managed to reproduce it now on symfony-demo as well. See https://github.com/symfony/demo/compare/main...dmaicher:symfony-demo:reproduce_issue_57075?expand=1

$ vendor/bin/simple-phpunit 
PHPUnit 9.6.16 by Sebastian Bergmann and contributors.

Testing 
EEEE...............................................               51 / 51 (100%)

Time: 00:01.626, Memory: 64.50 MB

There were 4 errors:

1) App\Tests\Command\AddUserCommandTest::testCreateUserNonInteractive with data set #0 (false)
ReflectionException: Property Proxies\__CG__\App\Entity\User::$email does not exist

@dmaicher
Copy link
Contributor Author

Seems to be caused by #38662

ping @wkania

@dmaicher dmaicher changed the title [DoctrineBridge][PropertyInfo] issues with UniqueEntityValidator on 7.1-RC1 [DoctrineBridge] issues with UniqueEntityValidator on 7.1-RC1 May 23, 2024
@dwalck
Copy link

dwalck commented May 24, 2024

same for me

@dmaicher
Copy link
Contributor Author

Added a failing test case here: https://github.com/symfony/symfony/compare/7.2...dmaicher:symfony:issue_57075?expand=1

Will see if I find the time in the next days to take a look at fixing it

@wkania
Copy link
Contributor

wkania commented May 29, 2024

Good, you found it. I broke untested code.

xabbuh added a commit that referenced this issue May 31, 2024
…ject (HypeMC)

This PR was merged into the 7.1 branch.

Discussion
----------

[DoctrineBridge] Fix `UniqueEntityValidator` with proxy object

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #57075
| License       | MIT

Before #38662, `$fieldValue = $class->reflFields[$fieldName]->getValue($entity);` was used to get the value of a property, so it makes sense to keep using it when the object is an entity.

Commits
-------

99f279b [DoctrineBridge] Fix `UniqueEntityValidator` with proxy object
@xabbuh xabbuh closed this as completed May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants