On unsubscribe of a mail address some things are still pretty unclean...

In simplenews.module
function simplenews_unsubscribe_user

We should reuse the existing subscriber object and not define a new one.
$subscriber->newsletter_subscription[$tid']

Also the subscriber should not finally contain
$subscriber->tids[$tid] = $tid;
It should be unset.

Also the $subscriber->newsletter_subscription is not continued (set, unset) correctly ... This affects unsubscribe and subscribe.

CommentFileSizeAuthor
#1 cleanup.patch2.64 KBberdir

Comments

berdir’s picture

Status: Active » Needs review
StatusFileSize
new2.64 KB

The attached patch cleans this up a bit and also adds tests to actually verify that subscribe/unsubscribe works with single opt-in. The old code actually didn't have any useful assertions ;)

Note that the tests don't actually verify these changes. The only way to verify this would be to add a test module and implement those hooks, because that is the only way where the incomplete/wrong $subscriber object is actually available.

miro_dietiker’s picture

Status: Needs review » Reviewed & tested by the community

Looks fine, consistent now. Thank you for fixing this.

berdir’s picture

Status: Reviewed & tested by the community » Fixed

Commited.

Status: Fixed » Closed (fixed)

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