【发布时间】:2017-04-20 06:19:36
【问题描述】:
我正在使用 Symfony 3.0.9 和 FosUserBundle 来构建我的应用程序。我最近做了一个作曲家更新,现在我无法通过 UserManager 或命令行创建用户。错误是Integrity constraint violation: 1048 Column 'salt' cannot be null。即使我在构造方法中显式调用 parent::__construct() 也会发生此错误,如下所示:
/**
* constructor.
*/
public function __construct()
{
parent::__construct();
}
如果我像$user->setSalt('87234hjjdwshjdsjkds')这样调用setSalt方法也会失败
解决这个问题的所有努力都失败了,所以我开始密切关注我的 composer update 命令,这是一些输出:
Updating dependencies (including require-dev)
Removing twig/twig (v1.24.1)
Installing twig/twig (v1.28.2)
Loading from cache
Removing symfony/polyfill-util (v1.2.0)
Installing symfony/polyfill-util (v1.3.0)
Loading from cache
...
Removing symfony/polyfill-intl-icu (v1.2.0)
Installing symfony/polyfill-intl-icu (v1.3.0)
Loading from cache
Removing psr/log (1.0.0)
Installing psr/log (1.0.2)
Loading from cache
Removing doctrine/cache (v1.6.0)
Installing doctrine/cache (v1.6.1)
Loading from cache
...
Removing doctrine/orm (v2.5.4)
Installing doctrine/orm (v2.5.5)
Loading from cache
Removing sensiolabs/security-checker (v3.0.2)
Installing sensiolabs/security-checker (v4.0.0)
Loading from cache
Removing nikic/php-parser (v2.1.0)
Installing nikic/php-parser (v2.1.1)
Loading from cache
...
Removing doctrine/doctrine-migrations-bundle (1.1.1)
Installing doctrine/doctrine-migrations-bundle (v1.2.0)
Loading from cache
...
Removing phpspec/phpspec (2.5.1)
Installing phpspec/phpspec (2.5.5)
Loading from cache
Removing doctrine/data-fixtures (v1.2.1)
Installing doctrine/data-fixtures (v1.2.2)
Loading from cache
Updating friendsofsymfony/user-bundle dev-master (147ca68 => 7261f7a)
Checking out 7261f7aa143b4bfdb0b7ddc5df208067fa7be698
如您所见,FOSUSERBUNDLE 已更新。
恢复作曲家更新,删除我的供应商目录并运行作曲家安装修复它。这将其归结为更新。这就是问题所在。
如果有人知道我如何更新并且仍然有一个可以工作的应用程序,我将感谢您的 cmets 和反馈。
【问题讨论】:
-
您是否更新了架构?据我记得,之前的更新删除了一些 FOSUser 实体字段,也许您尝试在不再存在的字段上插入数据。
-
感谢@BartBartoman,我将运行“composer update”并重试。
-
是的!那行得通!在作曲家更新后,我更新了架构并更新了用户表。这太棒了。谢谢
-
不客气。作为一个快速提示,每次您再次开始处理项目时,只需花时间拉取、更新依赖项和更新架构。
标签: php doctrine-orm composer-php symfony fosuserbundle