user account settings bug

NaX - November 16, 2005 - 22:08
Project:Privatemsg
Version:4.6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:mindless
Status:closed
Description

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.

#1

shpchp - December 10, 2005 - 15:28

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)) {

#2

solipsist - March 14, 2006 - 14:07

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

#3

soter82 - March 15, 2006 - 00:06

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).

#4

NaX - March 15, 2006 - 06:44

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.

#5

blarg - March 23, 2006 - 07:05

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.

#6

mindless - August 11, 2006 - 15:38
Assigned to:Anonymous» mindless
Status:active» fixed

Fix applied to DRUPAL-4-6 branch.

#7

Anonymous - August 25, 2006 - 15:46
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.