In privatemsg's implementation of user hook, there is a rather inane piece of code that works on ops 'insert' and 'update'

It is totally redundant and actually breaks the code when other modules create other categories because when those settings are saved the privatemsg settings get turned to 0.

~line 94

    case 'insert':
    case 'update':
      if (!isset($edit['privatemsg_mailalert'])) {
        $edit['privatemsg_mailalert'] = 0;
      }
      if (!isset($edit['privatemsg_allow'])) {
        $edit['privatemsg_allow'] = 0;
      }
      break;

This entire block of code is totally redundant. Removing it leaves everything functional for me.

The bug:

Running when the hook is called with "update" from another user settings category makes it default to zero, because the checkboxes are not on the category pages and therefore cannot be set. They will fail the isset test and the settings will revert to 0. I imagine this would also break when used with custom profile categories.

Removing this code fixes this problem. There should be no negative side effects but try anyway.

Comments

Ayman’s picture

I can comfirm the bug, and removing the code seems to fix the problem for me as well.

pegmonkey’s picture

+1.. works for me too..

onionweb’s picture

this code should be in "case:register"

it would then set the default email notification to off when new accounts are created.

Having the default notifcation set to on is a sure way to get your site users to tag your site as a spam source.

In fact, I received notice from AOL today that this is happening on a site: users tagging PM notifications as spam because they have forgotten they signed up on the site 6 months ago, or can't figure out how to login and turn off motifications, or just don't have the time to.

mindless’s picture

Status: Needs review » Reviewed & tested by the community

I have included this change in 67612.

I also agree with comment #3, so I changed a couple lines so _mailalert defaults to 0 when !isset.

mindless’s picture

Status: Reviewed & tested by the community » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)