I have managed to reproduce this bug with a stock install of Drupal 7.14 and the 2.x-dev (2012-Apr-26) version of privatemsg.
- Give users permission to disable private messages.
- Go to an edit user account page.
- Uncheck the box to enable private messages.
- Save.
- Go back to the same edit user account page.
- Check the box to enable private messages.
- Save.
At this point, an error like the following will be thrown:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'value' at row 1: UPDATE {pm_setting} SET value=:db_update_placeholder_0 WHERE ( (type = :db_condition_placeholder_0) AND (id = :db_condition_placeholder_1) AND (setting = :db_condition_placeholder_2) ); Array ( [:db_update_placeholder_0] => [:db_condition_placeholder_0] => user [:db_condition_placeholder_1] => 8 [:db_condition_placeholder_2] => disabled ) in privatemsg_set_setting() (line 3395 of /Volumes/Bullfrog/patrick/Sites/acquia-drupal/sites/all/modules/privatemsg/privatemsg.module).
The website encountered an unexpected error. Please try again later.
I have reproduced this on a local MAMP development environment and on Pantheon's servers.
Comments
Comment #1
seddonym commentedThe problem here seems to be that sometimes privatemsg_set_setting() receives a boolean value for the setting, but the database schema specifies an integer value.
Specifically here's the call to privatemsg_set_setting() from within privatemsg_user_update(), which is what's called when the user updates whether or not they want to disable private messages.
You'll see that the value of $disabled is boolean.
The attached patch includes a test in privatemsg_set_setting() to typecast any boolean values into integer values before inserting them into the database:
Comment #3
seddonym commentedHmm that last patch failed testing, relating to privatemsg_filter module. Is it possible that these errors are present in the latest dev version anyway? Having had a brief look at the tests that failed I'd be surprised if the change I made would have caused these problems, though I could be wrong.
Still it's not a priority for me at the moment to get this fix working with privatemsg_filter module (which I don't use) so if anyone does use that module feel free to take a look!
Comment #4
Maks commentedIn my case patch posted by seddonym works perfectly.
I have installed 7.x-2.x-dev
Comment #5
bogeyman commentedWhen disabling the users' private message, a new row is inserted to pm_setting table to mark that the user's private message is disabled. But where we try to re-enable it again, the row should be deleted which this module didn't do.
Here is the patch to fix the bug. I also add a new checking, if the edited user has no permission re-enable his/her private message, the administrator can't disable his/her private message.
Comment #6
bogeyman commentedRe-submit the patch for automated testing.
Comment #7
ptmkenny commentedThanks, this fixed the issue for me.
Comment #8
Rosamunda commentedI can confirm that too. It works for me too.
Comment #9
berdirSorry for the long wait, committed and pushed. Marking as fixed, please change to 6.x-2.x and re-open if the same error exists there as well.