Closed (fixed)
Project:
Simplenews
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
3 Jan 2012 at 06:40 UTC
Updated:
4 Jan 2014 at 01:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
berdirShorten title.
Comment #2
berdirThis is quite a nice and bigger clean-up than I expected.
There were two big differences between get_subscription() and the subscriber_load_*() functions:
- Only get_subscriptions() also loaded the corresponding subscriptions. Ported this code over to the load function. Except this line "$subscription->language = user_preferred_language($subscription)->language;", which is imho completely wrong (overriding the language for all loaded subscribers with the one for the current user...). For consistency, simplenews_subscriber_delete() now also deletes the subscriptions. Btw, what's supposed to happen when you cancel your/a users account? we disable when he gets disabled but currently do nothing when deleted/canceled.
- get_subscription() returned a dummy, empty subscription object if it didn't find something for the passed in arguments. This behavior was used in exactly two places (multi-signup and subscription page), where it essentially meant authenticated user vs. anon. Replaced with a more direct check. And there were actually multiple checks that explictly checked against this behavior. Removed completely.
So, as a result, the patch drops simplenews_get_subscription() and simplenews_subscriber_defaults() and ports the existing code over to the new simplenews_subscriber_load_by_mail() function.
The result is quite nice I think:
And quite bit of the new code is actually documentation...
Comment #4
berdirtests!! ;)
- There is actually a place where we need a dummy subscriber object and that is when sending a test mail to a mail address which is not subscribed. Dealt with that.
- Stop trying to generate generate tokens when the necessary data isn't provided.
- Updated for #706904: List of outstanding, unconfirmed, anonymous subscription requests.
Comment #5
berdirOh and another change I forgot to mention.
Renamed simplenews_subscriber*s*_load_multiple() to simplenews_subscriber_load_multiple(). Similar to #1387624: Rename/merge duplicating/confusingly named functions
Comment #7
berdirFixed typos.
Would be good to add some tests for the admin subscription form, will do so before commiting this.. That's one of the major code parts that's touched here that is missing test coverage
Comment #8
berdirAnd now with patch.
Comment #10
berdirSee patch file name ;)
Comment #11
berdirComment #12
miro_dietikerLooks great, this stuff. Love to have cleaner APIs for that loading thingies.
Comment #13
berdirAdded tests for the admin settings form. Found and fixed a bug in simplenews_user_is_subscribed() which didn't check if the subscriber was activated.
Will commit once green.
Comment #14
berdirCommited.