Closed (fixed)
Project:
Simplenews
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
25 May 2019 at 20:28 UTC
Updated:
16 Jul 2019 at 10:09 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
adamps commentedComment #3
adamps commentedComment #4
adamps commentedComment #5
berdirNot sure if we ported everything to 8.x, but there are/used to be newsletter options for hidden/automatic signup when registering, which should basically cover this? Not when creating users in a different way than the register form maybe, but not sure if it should really apply there.
Comment #6
adamps commented@Berdir yes hidden newsletters work in 8.x and that would be a workaround, although it is a little untidy to force existence of the newsletter and subscriptions that aren't actually used. As you say it only covers users created through the UI and it does not apply to pre-existing users.
I have updated the IS with my latest idea for this issue.
Comment #7
jonathanshawIS 1 & 3 yes. Seems like a clean and safe solution.
With IS 2 I'm not sure we've really got the right model nailed for what would be most helpful in these base classes, but I also think it doesn't matter much because it's all been opened up by moving addToSpool(), you've made rich examples, and we're only talking about saving people a few lines of code. Therefore I suggest you do whatever is quick and easy here, I don't see optimising further should be a priority. In my project I'm expecting to make only minimal use of the base classes and not use their helper methods.
Comment #8
adamps commented@jonathanshaw thanks, yes I agree. Item 2 will be a simple change and derived classes are free to ignore it.
Comment #9
adamps commentedComment #10
adamps commentedComment #12
adamps commentedComment #13
adamps commentedComment #14
jonathanshawThe interface says this function returns
\Drupal\user\UserInterface|null.But user_load_by_mail returns false if there is no user with that mail, and in this case the method previously returned null.
.
This doesn't seem implemented?
This change seems unrelated - just calling your attention to that in case it was unintentional. If I understand right, it only effects persistent subscriber entities not temporary ones.
It also has the effect of preventing the creation of a persistent subscriber whose email is not the same as the email on his user account (because ::fillFromAccount() syncs these). But if we're insisting these are the same, why bother storing an user id reference on the subscriber at all?
This comment, and maybe variable name, is possibly misleading (although I struggle to do better) as "uid" here is not a field to be set on the spool.
Worth a comment explaining?
Comment #15
adamps commented1. Please bear with me just a little bit longer for the tests. I would like to get all the related issues done and working first so that I know the whole scenario works. This avoids the case where I would write tests then change them later.
2. Ah thanks I get it now! Fixed.
3. See 4.
4. This is the code that deals with 3. by calling
fillFromAccount(). It seemed neater to let the Subscriber entity do it.Not true - postCreate is called when the PHP object is created and does not rely on saving a persistent entity.
That is already prevented. Every time the User is saved it overwrites the Subscriber - see
simplenews_user_presave().I guess it allows code to tell there is a related user without a database lookup. Anyway I'm not going to change it now.
5. Done.
6. I think the comment from 5. covers it.
Revised patch coming up soon. I just spotted a bug that the code doesn't handle the case where the uid lookup fails.
Comment #16
jonathanshawAll makes sense, thanks Adam!
Comment #17
adamps commentedIn SpoolList.php added a check
!$subscriber->getMail()which covers the case that the User was deleted and plus any other random error that leads to a recipient without an email.Comment #18
adamps commentedComment #20
adamps commentedRandom fail
Comment #22
adamps commented