I need some one that knows better than me to check this for me. In the 4.6 version line 67 and 68. I think the $edit var is being used as a object when I think it is an array.

This

isset($edit->privatemsg_allow) ? $edit->privatemsg_allow : (isset($user->privatemsg_allow) ? $user->privatemsg_allow : 1)

isset($edit->privatemsg_mailalert) ? $edit->privatemsg_mailalert : (isset($user->privatemsg_mailalert) ? $user->privatemsg_mailalert : 1)

should be this

isset($edit['privatemsg_allow']) ? $edit['privatemsg_allow'] : (isset($user->privatemsg_allow) ? $user->privatemsg_allow : 1)

isset($edit['privatemsg_mailalert']) ? $edit['privatemsg_mailalert'] : (isset($user->privatemsg_mailalert) ? $user->privatemsg_mailalert : 1)

In the CVS version it is using the new forms api but it is using $edit as an array.

The reason I found this because this was not working for me. The checkboxes were not staying checked. So my users were constantly enabling and disabling private message for their user accounts. The thing that confused me was that it worked on my development server (php 4.3.10) but not Live (php 5.0.4). I don't know why the conditional statements work out differently, but when I change it to refer to $edit as an array it started working live.

Comments

jian he’s picture

the correct solution should be:

@@ -42,7 +42,7 @@
/**
* Implementation of hook_user().
*/
-function privatemsg_user($type, $edit, &$user, $category = NULL) {
+function privatemsg_user($type, &$edit, &$user, $category = NULL) {
switch ($type) {
case 'view':
if (user_access('access private messages') && (isset($user->privatemsg_allow) ? $user->privatemsg_allow : 1)) {

solipsist’s picture

Nax: Thanks for sharing!
shpchp: Does your code work with 4.6.6?

salvatoreco’s picture

I've patched (not upgraded) a 4.6.5 version to 4.6.6 and the code for this bug seems to work correctly. I don't know if it will work with a full version 4.6.6 (but I think it should work).

NaX’s picture

I have not tried shpchp code, but I have been using my code on a site for about 3 months now and it seems to work just fine.

blarg’s picture

I tried the code posted by shpchp and it does not seem to fix the issue for me with Drupal 4.6.6 and PHP 5.1.2-1+b1.

Using the original code posted in this thread fixes the issue for me.

mindless’s picture

Assigned: Unassigned » mindless
Status: Active » Fixed

Fix applied to DRUPAL-4-6 branch.

Anonymous’s picture

Status: Fixed » Closed (fixed)