Fosuserbundle: Could not convert database value "" to Doctrine Type array

Created on 7 Oct 2014  路  2Comments  路  Source: FriendsOfSymfony/FOSUserBundle

I discovered that when an empty form is submitted to FOSUserBundle:Resetting:sendEmail, the following error is thrown: "Could not convert database value "" to Doctrine Type array in path\to\Test\vendor\doctrine\dbal\lib\Doctrine\DBAL\Types\ConversionException.php at line 46 ". Since hitting the submit button by mistake is a common user action, it would be better to have the form fail validation with a message like "A username or email is required.".

I suggest adding a check to sendEmailAction():

$username = $this->container->get('request')->request->get('username');
if(empty($username)) return $this->container->get('templating')->renderResponse('FOSUserBundle:Resetting:request.html.'.$this->getEngine(), array('empty_username' => true));

And a message to request_content.html.twig:

{% if empty_username is defined %}
{{ 'resetting.request.empty_username'|trans({}, 'FOSUserBundle') }}</p>
{% endif %}

with appropriate entries in the translation files.

I had this issue with version 1.3.5 though I think it may have existed for some time.

Most helpful comment

I figured it out. Somehow there was a user in the database that didn't have a username. Once that row was removed, everything worked as expected.

All 2 comments

I tried locally, and I don't get a DBAL error in this case, but a message telling me that the user with an empty username does not exist.
I suspect the error is related to some code specific to your project.

I figured it out. Somehow there was a user in the database that didn't have a username. Once that row was removed, everything worked as expected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philrennie picture philrennie  路  4Comments

tinntsea picture tinntsea  路  5Comments

mehdimays picture mehdimays  路  6Comments

suhasini1212 picture suhasini1212  路  5Comments

soullivaneuh picture soullivaneuh  路  6Comments