Needs review
Project:
Simplenews Scheduler
Version:
4.0.0-beta1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Dec 2015 at 09:04 UTC
Updated:
7 Dec 2025 at 19:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
berdirAs discussed, this has nothing to do with subscriber skipping, it happens way, way earlier.
We already have hook_simplenews_scheduler_edition_node_alter(), we could add something there that allows to skip?
Comment #3
miro_dietikerAgree that there are two difference concepts of skipping. Skipping a newsletter in general, or skipping the per-user delivery.
If it is possible to configure a newsletter to consider per-recipient context to filter views or so... Then emptyness should be checked per recipient instance.
I don't know how much is possible with the site-building-only tools, what will always need code, but there is definitively demand for both.
Comment #4
hussainwebI've been looking for this.
My first instinct is that if the body field is empty (or renders to empty), it should not add an edition. But I realize that simplenews passes the whole node for rendering to the theming system and there might be other fields doing the rendering. I think this is best left to custom code but simplenews_scheduler should allow for a way to support it. The obvious hook that comes to mind is
hook_simplenews_scheduler_edition_node_alter.Right now, that wouldn't work because the very next line says $edition_node->save() and there is no handler for an exception. Should we make it so that if the alter hook sets a property, e.g.
simplenews_scheduler_skip_editionto TRUE, it should just exit?Comment #5
hussainwebHere is a patch with the idea.
Comment #7
berdirYeah, something like that.
What if we pass that as a separate variable to the alter hook, then we can explicitly document it and it is very obvious to anyone who implements this hook how to do this if they want to?
Comment #8
hussainwebI thought it was not worth adding another parameter to the alter call, which had only one left. But then I decided that documenting it is more important. Here are the changes, with some other improvements as well. One of the things I fixed from the previous patch is that the scheduler record is update to the next run time even if the mail is not sent.
Comment #10
hussainwebAs I noted in another issue, the failures seem to be unrelated to the patch.
Comment #11
hussainwebA tiny change in the .api.php documentation. I realize interdiff would be useful but I couldn't create it easily due to other patches. I hope the patch is not too long to review again. The only difference between #8 and this one is that this one contains
&$contextin .api.php.Comment #13
hussainwebSetting it back to Needs Review for unrelated failing tests.
Comment #14
Anonymous (not verified) commentedApplying this patch (#11) I get the following error:
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to ein_newsletters_simplenews_scheduler_edition_node_alter() must be an instance of NodeInterface, instance of Drupal\node\Entity\Node given, called in /web/core/lib/Drupal/Core/Extension/ModuleHandler.php on line 539 in ein_newsletters_simplenews_scheduler_edition_node_alter() (line 82 of modules/custom/ein_newsletters/ein_newsletters.module).
So, I understand that the patch actually changes what is being passed from Node to NodeInterface. Why is that?
Comment #15
Anonymous (not verified) commentedWhen I change in simplenews_schedule.api.php to \Drupal\node\Entity\Node and do the same in my hook, it works. So why NodeInterface?
Comment #16
berdirYour code is missing the use statement, that's not a fault of this patch. Doesn't matter if it's Node or NodeInterface, as long as it has the corresponding use or full namespace.
Comment #17
Anonymous (not verified) commentedThanks. You were right. Working now.
Comment #18
jocowoodI would like to suggest an addition. It would be useful to have the scheduler object in the hook, e.g. to get the interval length. Because of that I added a line of code to the patch #11 to store the scheduler object under the key 'scheduler' in the context array. My suggested patch is #12
Comment #19
jocowoodI updated my patch because it failed to apply
Comment #20
jocowoodHere is another version of the 'offer skip condition' patch because since the very first patch there was a problem with skipped editions, which nobody noticed yet. Skipped editions appear like the template under 'content' but without any additional fields changed. This is because the editions get saved on cloning. I added a 'delete' when the edition is skipped to solve this.
Comment #21
hussainwebI rerolled the patch for 2.0.x version.
Comment #23
hussainwebIgnore the patch in #21. I have forgotten how to create patches without a difftool. :D
I created a MR instead. Please review.
Comment #24
jaroslav červený commentedI created patch by #22
Comment #25
drupgirl commentedThis feature is fundamental.
This patch needs a re-roll.
Comment #26
jocowoodI rerolled the patch for 4.0.0-beta1
Should this be a feature in the next beta version? I'll have to rebase the merge request source branch, so anybody could do a review.
Comment #27
jocowoodI restarted the issue fork branch based on current 4.x and applied the latest patch. The merge request is ready for a review again.
Comment #28
drupgirl commentedIs it possible to simply skip sending when the created newsletter body field is empty? This seems like it would be automatic, but evidently not.
Comment #29
drupgirl commentedComment #30
jocowoodYou can write your own skip condition in hook_simplenews_scheduler_edition_node_alter. Here is an example:
Comment #31
jaroslav červený commented#26 patch work fine for me.