From 65950b5a8d2ac61e603aa85f4e4c835c726d5e50 Mon Sep 17 00:00:00 2001 From: michelvaldrighi Date: Mon, 31 Jan 2005 19:00:25 +0000 Subject: [PATCH] moving the pop3->delete call to the end of the loop so that emails are deleted if and only if a post is made successfully git-svn-id: http://svn.automattic.com/wordpress/trunk@2176 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-mail.php | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/wp-mail.php b/wp-mail.php index 4ef58db24..5a9d8c208 100644 --- a/wp-mail.php +++ b/wp-mail.php @@ -24,14 +24,6 @@ for ($i=1; $i <= $count; $i++) : $message = $pop3->get($i); - if(!$pop3->delete($i)) { - echo '

Oops '.$pop3->ERROR.'

'; - $pop3->reset(); - exit; - } else { - echo "

Mission complete, message $i deleted.

"; - } - $content = ''; $content_type = ''; $boundary = ''; @@ -144,6 +136,11 @@ for ($i=1; $i <= $count; $i++) : $post_ID = wp_insert_post($post_data); + if (!$post_ID) { + // we couldn't post, for whatever reason. better move forward to the next email + continue; + } + do_action('publish_phone', $post_ID); echo "\n

Author: $post_author

"; @@ -152,20 +149,28 @@ for ($i=1; $i <= $count; $i++) : if (!$post_categories) $post_categories[] = 1; foreach ($post_categories as $post_category) : - $post_category = intval($post_category); + $post_category = intval($post_category); - // Double check it's not there already - $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category"); + // Double check it's not there already + $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category"); - if (!$exists && $result) { - $wpdb->query(" - INSERT INTO $wpdb->post2cat - (post_id, category_id) - VALUES - ($post_ID, $post_category) - "); + if (!$exists && $result) { + $wpdb->query(" + INSERT INTO $wpdb->post2cat + (post_id, category_id) + VALUES + ($post_ID, $post_category) + "); + } + endforeach; + + if(!$pop3->delete($i)) { + echo '

Oops '.$pop3->ERROR.'

'; + $pop3->reset(); + exit; + } else { + echo "

Mission complete, message $i deleted.

"; } -endforeach; endfor;