I have two newsletters set up. Both are set to "default off" on user registration form.

- When I register for a new account and leave both checkboxes unchecked, I get subscribed to both newsletters.
- When I register for a new account and check one of the checkboxes, I get subscribed to the one I checked.

Digging further, it seems that when the checkboxes are left empty, an empty array of tids is passed in simplenews_user_insert() to simplenews_categories_load_multiple(). That defaults in returning all newsletters and thus the new user gets subscribed to them all.

Comments

Sborsody’s picture

Status: Active » Needs review
StatusFileSize
new1.13 KB

needed to check for an empty array. here's what worked for me.

simon georges’s picture

I can confirm the bug & that the patch is working.

I'm just wondering if the bug is right there or if we should modify the simplenews_categories_load_multiple() function.

upupax’s picture

confirm the issue.
the patch solved the problem.

Sborsody’s picture

Is simplenews_categories_load_multiple() not supposed to load all newsletters in such a case? I sort of like not hitting the database to do a newsletter load if checkboxes are empty.

simon georges’s picture

Status: Needs review » Reviewed & tested by the community

@Sborsody, you're right (meaning I'll commit your patch this week-end).

But I don't like the fact that passing an empty array as a condition to simplenews_categories_load_multiple() returns something ;-)

miro_dietiker’s picture

Status: Reviewed & tested by the community » Fixed

Committed.
@Simon: this seems to be common behaviour.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.