Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DoctrineBridge] Fix UniqueEntity for non-integer identifiers #59126

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

Conversation

GiuseppeArcuti
Copy link
Contributor

Q A
Branch? 7.2
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #58883
License MIT

Failed to reproduce the issue reported in #58883

@carsonbot

This comment was marked as resolved.

@OskarStark OskarStark changed the title [DoctrineBridge] Fix UniqueEntity for non-integer identifiers [DoctrineBridge] Fix UniqueEntity for non-integer identifiers Dec 7, 2024
@nicolas-grekas
Copy link
Member

@GiuseppeArcuti can you, now that there is a reproducer on the issue?

@nicolas-grekas
Copy link
Member

What should be done next here? Anyone up to help finish this PR?

@norkunas
Copy link
Contributor

norkunas commented Mar 12, 2025

What should be done next here? Anyone up to help finish this PR?

Either it should support symfony uid properly, or add an extension point to add custom equality checkers or some sort of callback option?

@wkania
Copy link
Contributor

wkania commented Apr 23, 2025

No one tagged me.
@GiuseppeArcuti , thanks for creating the test.
There is, of course, an issue - I mistakenly assumed that the identifiers were scalars.
If you're still working on this bug, replace line 200 in the UniqueEntityValidator class with the code below:

                if ($fieldValues[$identifierFieldName] instanceof \Stringable) {
                    $fieldValues[$identifierFieldName] = (string) $fieldValues[$identifierFieldName];
                }
                if ($propertyValue instanceof \Stringable) {
                    $propertyValue = (string) $propertyValue;
                }
                if ($fieldValues[$identifierFieldName] !== $propertyValue) {

This should resolve the issue in most cases.
There’s still a separate problem with object-type identifiers that may not have a toString method. However, that’s part of a different feature (another PR) that will introduce something like a normalizer.
I’ll take care of that in a new PR.

Anyone up to help finish this PR?

@nicolas-grekas If the PR has been abandoned, what’s the procedure in that case?

@OskarStark
Copy link
Contributor

You can just open a new PR and reference this one and the issue, thanks

@nicolas-grekas
Copy link
Member

Continued in #60275, thanks for the PR @GiuseppeArcuti

fabpot added a commit that referenced this pull request May 10, 2025
…tifiers (GiuseppeArcuti, wkania)

This PR was merged into the 7.2 branch.

Discussion
----------

[DoctrineBridge] Fix UniqueEntityValidator Stringable identifiers

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

`@GiuseppeArcuti` , thanks for creating the test in [PR](#59126).

More info in the [comment](#59126 (comment)).

Commits
-------

b0f012f [DoctrineBridge] Fix UniqueEntityValidator Stringable identifiers
572ebe8 [DoctrineBridge] Fix UniqueEntity for non-integer identifiers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.