Problem/Motivation
When there's only hidden subscriptions, and no "regular" ones, the registration form processing doesn't process the hidden subscriptions.
Steps to reproduce
- Add one or multiple newsletters
- Make sure there are no newsletters with the options "Default on" or "Default off"
- Make sure there is at least one newsletter with the option "Silent"
- Register a new user
- See there is no Subscriber entity created and the settings aren't followed
Proposed resolution
- Update simplenews_user_profile_form_submit to ensure subscriptions and hidden are both processed.
Issue fork simplenews-3502221
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
daften commentedCreated an MR
I think #1689930: Silent and default subscription shouldn't depend on the registration form might be a better long-term fix, at least the approach to not rely on registration seems more sound to me, but that's a completely different approach.
Comment #5
adamps commentedThanks - one comment please.
Comment #6
daften commentedI processed with what I think was meant, it wasn't 100% clear to me, but removing the $subscriptions check was a logical thing to do and a stupid oversight. Thanks!
Comment #7
erwangel commentedWarning: Undefined variable $subscriptions in simplenews_user_profile_form_submit() lines 429 and 436 of simplenews.module. This is because the patch removes the $subscriptions initialization.
From the patch diff:
So, I think you have to set back the $subscriptions definition line
$subscriptions = array_filter($form_state->getValue('subscriptions', []));Comment #8
adamps commented#7 seems correct
Comment #10
loze commentedRebased onto
4.xand restored the$subscriptionsline per #7.Added
SimplenewsSilentRegistrationTest, covering the case that triggers this: every newsletter set tonew_account: silent, so no subscription checkboxes render at all.SimplenewsAdministrationTestalways has an "on" newsletter alongside the silent ones, so a ticked checkbox carries the hidden ones through and the bug never surfaces.Verified failing before the fix and passing after.
Comment #12
adamps commentedThanks