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

Skip to content

[DoctrineBridge] Warning : undefined array key 0 in DoctrineLoader when using UniqueEntity constraint  #57396

Closed
@partulaj

Description

@partulaj

Symfony version(s) affected

7.1

Description

Hello,
When trying to upgrade to symfony 7.1 I get the following error.

!!  In DoctrineLoader.php line 129:
!!                                    
!!    Warning: Undefined array key 0 

After taking a look in the code the problem seems to be due to one of my entity validation constraints having a UniqueEntity constraint set like this :

App\Entity\User:
    constraints:
        - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: email

But if I define the constraint like below I don't get the warning :

App\Entity\User:
    constraints:
        - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity:
              fields: ['email']

How to reproduce

Add a UniqueEntity constraint without using the fields option and try to validate your entity

App\Entity\User:
    constraints:
        - Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity: email

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions