FOS 用户包:更改密码期间列 'salt' 不能为空

FOS User bundle : Column 'salt' cannot be null during change password

之前,应用程序在 PHP7.0、SF 3.1 和 FOS/UserBundle 2.0.

使用 SF 3.4 和 FOS/UserBundle 2.1 迁移到 PHP7.2 后,在更改密码期间,我遇到了:

$ bin/console fos:user:change-password toto pass1234

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null" ["exception" => Doctrine\DBAL\Exception\NotNullConstraintViolationException { …},"command" => "fos:user:change-password toto pass1234","message" => """  An exception occurred while executing 'UPDATE fos_user SET salt = ?, password = ? WHERE id = ?' with params [null, "y$LOb\/************************************wof0QpTGGpzGi", 2]:\n  \n  SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null  """] []

In AbstractMySQLDriver.php line 123:

  An exception occurred while executing 'UPDATE fos_user SET salt = ?, password = ? WHERE id = ?' with params [null, "y$LOb\/************************************wof0QpTGGpzGi", 2]:                                            

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


In PDOStatement.php line 144:

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


In PDOStatement.php line 142:

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


fos:user:change-password [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <username> <password>

已解决!

我编辑了文件 app/config/security.yml 并将 security.encoders.FOS\UserBundle\Model\UserInterface 的值(原为 bcrypt)替换为 argon2i

然后我清除缓存,重试,成功了!

https://symfony.com/doc/current/reference/configuration/security.html#reference-security-argon2i