From 62092631da786272c271ed34cd0f732adf6aaa62 Mon Sep 17 00:00:00 2001 From: argiepiano Date: Tue, 7 Feb 2023 18:10:15 -0700 Subject: [PATCH 1/2] Issue #20. Clear node entity cache after sending. Fixes #20 --- includes/simplenews.mail.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/includes/simplenews.mail.inc b/includes/simplenews.mail.inc index 2c8d393..c1c955c 100644 --- a/includes/simplenews.mail.inc +++ b/includes/simplenews.mail.inc @@ -634,6 +634,9 @@ function simplenews_send_status_update() { ->condition('nid', $nid) ->fields(array('status' => SIMPLENEWS_STATUS_SEND_READY)) ->execute(); + // Clear the node cache for sent newsletters so that the status shows + // correctly when loaded. + cache_clear_all($nid, 'cache_entity_node'); } } } From 437de22a9342d3dfd3a685b9077501b37846e18d Mon Sep 17 00:00:00 2001 From: argiepiano Date: Tue, 7 Feb 2023 20:58:02 -0700 Subject: [PATCH 2/2] Clear cache also for pending. --- includes/simplenews.admin.inc | 3 +++ includes/simplenews.mail.inc | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/includes/simplenews.admin.inc b/includes/simplenews.admin.inc index 97b269b..d9cdd0b 100644 --- a/includes/simplenews.admin.inc +++ b/includes/simplenews.admin.inc @@ -2070,4 +2070,7 @@ function simplenews_node_tab_send_form_submit($form, &$form_state) { simplenews_newsletter_save($newsletter); backdrop_set_message(t('The newsletter will be sent when the content is published.')); } + // Clear the node cache for this node so that the status shows correctly when + // loaded. + cache_clear_all($node->nid, 'cache_entity_node'); } diff --git a/includes/simplenews.mail.inc b/includes/simplenews.mail.inc index c1c955c..895915c 100644 --- a/includes/simplenews.mail.inc +++ b/includes/simplenews.mail.inc @@ -634,8 +634,8 @@ function simplenews_send_status_update() { ->condition('nid', $nid) ->fields(array('status' => SIMPLENEWS_STATUS_SEND_READY)) ->execute(); - // Clear the node cache for sent newsletters so that the status shows - // correctly when loaded. + // Clear the node cache for this node so that the status shows correctly + // when loaded. cache_clear_all($nid, 'cache_entity_node'); } }