Index: simplenews.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simplenews/simplenews.module,v retrieving revision 1.220.2.19 diff -u -p -r1.220.2.19 simplenews.module --- simplenews.module 23 Jan 2010 10:28:20 -0000 1.220.2.19 +++ simplenews.module 23 Jan 2010 21:28:42 -0000 @@ -429,6 +429,14 @@ function simplenews_nodeapi(&$node, $op, if ($result) { drupal_set_message(t('Newsletter %title was deleted.', array('%title' => $node->title))); } + + // Check if pending emails of this newsletter issue exist and delete these too. + $pending = simplenews_get_spool(SIMPLENEWS_SPOOL_PENDING, $node->nid, $node->vid); + if (!empty($pending)) { + simplenews_update_spool(array_keys($pending), array('status' => SIMPLENEWS_SPOOL_DONE, 'error' => TRUE)); + drupal_set_message(t('Newsletter %title was deleted but had pending emails. They can no longer be sent.', array('%title' => $node->title)), 'warning'); + watchdog('simplenews', 'Newsletter %title deleted with pending emails. Emails can no longer be sent.', array('%title' => $node->title), WATCHDOG_ALERT); + } break; case 'load': $node->simplenews = db_fetch_array(db_query('SELECT * FROM {simplenews_newsletters} WHERE nid = %d', $node->nid));