Problem description

There is a lot of code relating to subscriber creation/lookup/sync that is subtly wrong, confusing or unnecessarily verbose. This is the cause of some bugs and also makes fixing others much more difficult.

Proposed resolution

  1. In Subscriber::loadByMail() check for blank mail and return FALSE. Hence calling code does not need to.
  2. When looking up a subscriber from a User, always use UID rather than mail.
  3. Subscriber::getUser() should check for uid 0 and return NULL.
  4. Avoid unnecessary synchronisation if there are no shared fields.
  5. Move all synchronising into Subscriber::fillFromAccount(). Always synchronise and always include the full set of fields.
  6. Add an optional 'create' flag to Subscriber::loadByMail() and Subscriber::loadByUid(). If the flag is set, when lookup fails the function returns a new subscriber initialised from the supplied uid/mail.

#3031919: Bugs if user has blank email address is mostly solved by 1) and 2).
#2937372: Subscriber postSave method saves/invalidates anonymous user (uid 0) is solved by 3) and further improved by 4).

Comments

AdamPS created an issue. See original summary.

adamps’s picture

Status: Active » Needs review
StatusFileSize
new24.04 KB

Status: Needs review » Needs work

The last submitted patch, 2: simplenews.subscriber-tidy.3062530-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

adamps’s picture

adamps’s picture

adamps’s picture

adamps’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: simplenews.subscriber-tidy.3062530-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

adamps’s picture

Status: Needs work » Needs review
StatusFileSize
new24.51 KB
new2.25 KB

Status: Needs review » Needs work

The last submitted patch, 9: simplenews.subscriber-tidy.3062530-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

adamps’s picture

Issue summary: View changes
adamps’s picture

Title: Tidy up subscriber creation/lookup/sync » Fix and simplify subscriber creation/lookup/sync
adamps’s picture

Status: Needs work » Needs review
StatusFileSize
new24.56 KB
new412 bytes
adamps’s picture

Issue tags: +Plan to commit

  • AdamPS committed 67f4083 on 8.x-2.x
    Issue #3062530 by AdamPS: Fix and simplify subscriber creation/lookup/...
adamps’s picture

Status: Needs review » Fixed
Issue tags: -Plan to commit
adamps’s picture

Status: Fixed » Needs review
StatusFileSize
new1.65 KB

Minor correction: getUserSharedFields no longer needs to be part of the public interface

  • AdamPS committed 387a8d8 on 8.x-2.x
    Issue #3062530 by AdamPS: Fix and simplify subscriber creation/lookup/...
adamps’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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