I am trying to create a new user from the command line and get this error:
Warning: array_search() expects parameter 2 to be array, null given
in /vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Model/User.php line 368
When trying to create a user by registering over the webinterface I get this:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null
Logging in with an already existing user works. Also updating a profile and changing the password. Just creating new users doesn't work.
I am using v 1.3.1 in a very plain setup and haven't found any solution yet.
Any ideas?
Fixed!
I had a custom constructor method in my User entity. There I had forgotten to call the parent's constructor with parent::__construct();
Maybe it help someone. You can see this error when use bcrypt encoder.
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'salt' cannot be null
To solve this issue just add mapping override for salt attribute in your User class (make it nullable)
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\AttributeOverrides({
* @ORM\AttributeOverride(
* name="salt",
* column=@ORM\Column(name="salt", type="string", nullable=true)
* )
* })
*/
class User extends BaseUser {
...
}
OR: don't forget update your schema. If error happend after composer update!
bin/console doctrine:schema:update --force
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With