Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello.
Will be short.
I see "Recoverable fatal error: Argument 1 passed to Drupal\Core\Session\AccountSwitcher::switchTo() must implement interface Drupal\Core\Session\AccountInterface, null given".
How to reproduce?
- Create a user
- Subscriber user to any newsletter
- Delete user from drupal (the site still has user uid in DB as subscriber)
- Try to send a newsletter by cron.
Going to provide a patch.
Comment | File | Size | Author |
---|---|---|---|
#8 | fatal_php_error_in_setcontext-2868214-8.patch | 890 bytes | Ruslan Piskarov |
|
Comments
Comment #2
Ruslan PiskarovAdding the patch.
Comment #3
Ruslan PiskarovComment #4
Ruslan PiskarovComment #5
Ruslan PiskarovI think in the feature will be better to implement the functionality -> then a user is deleting from a site, unsubscribe a user from each newsletter.
However, my hot patch works well, too.
Comment #6
Ruslan PiskarovComment #7
jonathanshawCould this be simplified to:
?
That's basically what you did for the other hunk:
Simplenews subscribers can be anonymous users, so I'm not sure this should be the automatic behavior. It's very easy to implement using hooks if a site wants to do that, probably not necessary to force it to be that way. It'd be harder to allow sites to prevent it than it is to allow sites to do it themselves.
Comment #8
Ruslan PiskarovHello @jonathanshaw .
I agree with you. Attaching a new patch.
Comment #9
Ruslan PiskarovComment #10
jonathanshawGreat! Sorry Ruslan, I forgot to say: the maintainers are probably going to want a test for this before they commit it.
Comment #11
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedConfirm that normal policy for this module is that tests are needed - in the long run it's the best way to get a stable module.
There can be exceptions for example if you are fixing a small bug in a certain feature, and there are no existing tests to adapt.
Comment #12
Ruslan PiskarovOk, will create test when will have time. Thank you. I don't have currency the project which uses simplenews.
Comment #13
AdamPS CreditAttribution: AdamPS at AlbanyWeb commentedIn simplenews_user_delete() there is code to delete the subscriber so maybe this is now fixed?