Skip to content

Commit

Permalink
moving the pop3->delete call to the end of the loop so that emails ar…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
michelvaldrighi committed Jan 31, 2005
1 parent dac4a93 commit 65950b5
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions wp-mail.php
Expand Up @@ -24,14 +24,6 @@

$message = $pop3->get($i);

if(!$pop3->delete($i)) {
echo '<p>Oops '.$pop3->ERROR.'</p></div>';
$pop3->reset();
exit;
} else {
echo "<p>Mission complete, message <strong>$i</strong> deleted.</p>";
}

$content = '';
$content_type = '';
$boundary = '';
Expand Down Expand Up @@ -144,6 +136,11 @@

$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<p><b>Author:</b> $post_author</p>";
Expand All @@ -152,20 +149,28 @@

if (!$post_categories) $post_categories[] = 1;
foreach ($post_categories as $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");

if (!$exists && $result) {
$wpdb->query("
INSERT INTO $wpdb->post2cat
(post_id, category_id)
VALUES
($post_ID, $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");

if (!$exists && $result) {
$wpdb->query("
INSERT INTO $wpdb->post2cat
(post_id, category_id)
VALUES
($post_ID, $post_category)
");
}
endforeach;

if(!$pop3->delete($i)) {
echo '<p>Oops '.$pop3->ERROR.'</p></div>';
$pop3->reset();
exit;
} else {
echo "<p>Mission complete, message <strong>$i</strong> deleted.</p>";
}
endforeach;

endfor;

Expand Down

0 comments on commit 65950b5

Please sign in to comment.