Creating a new user with a FOSUserBundle error

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 I try to create a user by registering via webinterface, I get the following:

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

Work with an existing user works. Also updating the profile and changing the password. Just creating new users does not work.

I use v 1.3.1 in a very simple setup and have not yet found a solution.

Any ideas?

+45
symfony fosuserbundle
Jan 11 '13 at 11:25
source share
2 answers

Fixed!

I had a custom constructor method in my User object. There I forgot to call the parent constructor with parent::__construct();

+141
Jan 11 '13 at 11:57
source share

Maybe this will help someone. You can see this error when using the bcrypt encoder.

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

To solve this problem, just add a mapping override for the salt attribute in your User class (make it valid)

 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: do not forget to update your circuit. If an error occurred after updating the composer!

 bin/console doctrine:schema:update --force 
+6
Dec 06 '16 at 2:11
source share



All Articles