0
votes

When implementing the following user story with the most recent version of FOSUserBundle (dev-master), instead of the form being invalidated because the passwords don't match, the data attempted to get persisted and fails because the passwords transformed to null values.

Why does this occur?

Feature Scenario:

Scenario: Trying to register with non verified password
  Given I am on the "Login" page
  And I follow "Sign Up"
  When I fill in the following:
    | Email         | [email protected] |
    | Username      | jdoe        |
    | Password      | bar         |
    | Verification  | foo         |
  And I press "Register"
  Then I should be on the Registration page
  And I should see "The entered passwords don't match"

Error:

An exception occurred while executing 'INSERT INTO user_account (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, password_requested_at, roles, credentials_expired, credentials_expire_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["jdoe", "jdoe", "[email protected]", "[email protected]", 1, "9z59n57td20cs88kw8gg8css80g0css", null, null, 0, 0, null, null, null, "a:0:{}", 0, null]:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'password' cannot be null

1

1 Answers

0
votes

This occurs if you are using the Symfony 2.4 Validation API with newer versions of FOSUserBundle, which has recently started using the new Validation API introduced in Symfony 2.5.

The Validation API version may have been explicitly defined in app/config/config.yml as a workaround for a bug in Symfony 2.5 that affected the UniqueEntity constraint on the User model (ie. signing up with the same email address): https://github.com/FriendsOfSymfony/FOSUserBundle/issues/1516#issuecomment-47204302

validation:
    enabled: true
    enable_annotations: true
    api: 2.4 # remove this line to fix the issue