[AdamPS] Updated text
Problem/Motivation
I can confirm the following bug:
- Set up 2 newsletters: A = silent, hidden; B = double,none
- Create a user
- As admin, edit this user's subscription using page admin/people/simplenews/edit/{simplenews_subscriber}. Click save without changing anything.
- Bug: the hidden newsletter is unsubscribed.
Proposed resolution
I found that this bug is solved by just part of the supplied patch, by changing simplenews_newsletter_get_visible to simplenews_newsletter_get_all.
User interface changes
None.
API changes
None.
[andrewbelcher] original text
Problem/Motivation
SubscriptionsFormBase has some special handling to preserve existing subscription information. This has only partial code implementation in SubscriberForm that results in all data being overwritten and lost. It also only processes visible subscriptions, but the form includes all subscriptions.
Proposed resolution
Quick solution would be to copy the handling over from SubscriptionsFormBase.
The better and longer term fix would probably be to move the process into SubscriptionWidget::extractFormValues which is where I think it should live and will mean any usage of the subscription widget will behave properly.
User interface changes
None.
API changes
Short term - fix the form. Longer term, move the processing logic to the widget for consistency.
| Comment | File | Size | Author |
|---|---|---|---|
| #26 | simplenews.overwrite-data.3013721-interdiff-23-26.txt | 2.41 KB | adamps |
| #26 | simplenews.overwrite-data.3013721-26.patch | 12.09 KB | adamps |
| #23 | simplenews.overwrite-data.3013721-23.patch | 12.33 KB | adamps |
Comments
Comment #2
andrewbelcher commentedHere's a patch for the quick fix in case anyone needs it. Might be worth committing and doing another release as this is causing data loss currently.
Comment #3
andrewbelcher commentedComment #4
adamps commentedSee description of priority field - this issue does not make the module completely unusable.
Comment #5
andrewbelcher commentedBut it does cause data loss:
Feel free to downgrade again if you still disagree.
Comment #6
adamps commentedTo me it's not clear that the "better and longer term fix" is much more complex that the short term fix. Might it make sense to put the better fix in straight away?
You are right there is data loss, but only in specific conditions something like this:
Comment #7
adamps commentedThe issue summary does not actually describe the exact symptoms of the bug. I can confirm there is a bug and have added IS text to describe it. The bug that I found seems to be solved by just part of the supplied patch, by changing
simplenews_newsletter_get_visibletosimplenews_newsletter_get_all.@andrewbelcher Please can you confirm, or let me know if you think I have missed anything?
I have added some tests and I will upload a new patch.
Comment #8
adamps commentedComment #10
adamps commentedThe failure was the ONLYTESTS patch as expected, so this looks ready.
Comment #11
adamps commentedWait a moment.....
I am surprised that the hidden newsletters are visible even on the admin page - that seems like a bug to me.
I have raised #3035521: Admin should not be able to modify subscriptions for hidden newsletters. We need to get that resolved before going any further here.
Comment #12
adamps commentedComment #14
adamps commentedBoth this bug and #3035521: Admin should not be able to modify subscriptions for hidden newsletters are caused by SubscriberForm missing important code in SubscriptionsFormBase. The solution is to update the base class of SubscriberForm to be SubscriptionsFormBase matching the other three subscription forms.
Then I had some confusion trying to understand and update the way these forms work. Here is the explanation of what I did:
Comment #15
adamps commentedComment #17
adamps commentedHmm tricker than I expected. I've added a detailed comment.
I am keen to avoid checking against empty mail because that breaks in the case of a user account with no email defined - we have another issue for that.
Comment #19
adamps commentedApologies to the others following this issue. Hopefully this time.....
Comment #21
adamps commentedOK, let's code back closer to the original code, but make allowance for #3031919: Bugs if user has blank email address coming up, and keep the really clear comments.
Comment #23
adamps commentedSo there is another bug relating to missing code from SubscriptionsFormBase. SubscriberForm must not allow edit of email address if the subscriber is a user.
Comment #24
adamps commentedOK, I plan to commit this in 1 week. Any comments/review before that would be appreciated.
Comment #25
berdirthis overlaps with the access issue, but it is also not quite the same both there and here.
Right now, the e-mail of an existing subscriber can't be changed, a new e-mail means a new subscription.
I guess it does make sense to allow that, but I'd suggest to finalize the access issue first and then drop this chunk from the patch?
$subscribed doesn't get initialized if $has_widget.. I guess it's also never accessed but that's actually not easy to figure out from reading the code. What if we just inline two calls we need into the conditions below? The overhead should be minimal. Thinking about how we could simplify the amount of (nested) ifs, but I can't think of anything obvious.
Overall, really nice that we fix a bug, add test coverage and extensive comments and still end up with 2 lines of code less than before.
I find it a bit strange to add commented out code with a todo.. doesn't seem like the right place as we are already deep in the form, building the actions. Might be better handled in the access control handler to never allow access to the form in the first place (we can't display a message then, though). My point is just leave this out completely.
Comment #26
adamps commented1.
I don't agree. Right now an admin can use SubscriberForm to change the email of an existing subscriber because right now SubscriberForm does not extend from SubscriptionsFormBase.
A) If the subscriber is also a user, this behaviour is highly undesirable because the User entity still stores the old email. This patch blocks that case.
B) If the subscriber is not a user, this behaviour is useful and is checked in the tests. The alternative of delete and create is tedious and loses important information about the subscription history. This chunk is needed in this patch to ensure that function continues to work.
Yes it overlaps with #3032167: Missing access check for subscriber mail field and both of them fix problem A in slightly different ways. The other issue has the correct long term fix, but is more risky, needs more tidy up and I'd rather leave it to give some time for people to spot problems in dev. This issue is safe and correct as it stands and is Critical due to data loss, so is blocking the next release.
2. Done
3. Done
Comment #28
adamps commentedAnother test glitch. I really need to fix these soon!
Comment #29
adamps commented@Berdir is it OK if I commit this one now please?
Comment #31
adamps commented