• When a user visits /user/XXX/simplenews and subscribes to a newsletter it creates two subscriber entities with the same email address.
  • There is only one subscription, so when the newsletter is sent it works correctly
  • It is confusing when viewing /admin/people/simplenews
  • It can go wrong with future changes. If the subscriber changes email address, just one of the subscriptions changes

Comments

AdamPS created an issue. See original summary.

adamps’s picture

Status: Active » Needs review
StatusFileSize
new563 bytes

It's all very baffling - layer upon layer of nested callbacks! Here is a patch that seems to solve it, but no idea what else it might break.

Status: Needs review » Needs work

The last submitted patch, 2: simplenews.duplicate-subscribers.3031018-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

adamps’s picture

Status: Needs work » Needs review

The test failures are just the same as in the base branch, so effectively this has passed the tests.

Here is some further explanation. There are three submit handlers, called in the following order:

  1. '::submitForm'
  2. '::save': creates the subscriber entity.
  3. '::submitUpdate': writes the subscription records.

With the checked-in code, submitForm calls submitUpdate, which writes the subscription records, auto-creating the subscription entity. Then step 2 save creates another entity.

adamps’s picture

Assigned: Unassigned » berdir

@Berdir please can you take a look when you have a moment. Only a one line fix, but it's very subtle so I don't want to commit without expert confirmation.

I just requeued the tests.

berdir’s picture

Assigned: berdir » Unassigned
Issue tags: +Needs tests

Yeah, definitely a bug, ugly. Test coverage should be fairly easy, we should have existing coverage for that form, so we "just" need to make sure that there's only one subscriber after that.

Wondering about existing data, should have an an update function that ensures there's only one subscriber per e-mail? Quite likely our entity should have a unique constraint on the e-mail, which might not have prevented this bug though.

adamps’s picture

Title: Duplicate subscribers » Account form creates duplicate subscribers
Status: Needs review » Needs work

Thanks @Berdir.

Yes I have already been thinking about follow-on actions to fix the duplicates and prevent future ones - see #2937251: Prevent duplicate subscribers.

I propose that we should prioritise fixing this issue for now as it's a one-line change and at least stops making the problem worse. I will add a test as you suggest.

The other issue is more complex with schema changes and update hooks so it will take more work.

adamps’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new5.61 KB
new5.06 KB

Status: Needs review » Needs work

The last submitted patch, 8: simplenews.duplicate-subscribers.TESTONLY.3031018-8.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

adamps’s picture

Status: Needs work » Needs review
Issue tags: +Plan to commit

@Berdir tests done

I propose that I tag all issues that I plan to commit after waiting 7 days like this "Plan to commit". It should make it easy for you to find/check them. If you want to indicate that you have checked it, then you could remove the tag and set to RTBC in which case I don't need to wait.

adamps’s picture

Status: Needs review » Fixed
Issue tags: -Plan to commit

  • 1f8563d committed on 8.x-1.x
    Issue #3031018 by AdamPS, Berdir: Account form creates duplicate...

Status: Fixed » Closed (fixed)

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