Changeset 2176

Show
Ignore:
Timestamp:
01/31/05 19:00:25 (4 years ago)
Author:
michelvaldrighi
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-mail.php

    r2174 r2176  
    2424 
    2525    $message = $pop3->get($i); 
    26  
    27     if(!$pop3->delete($i)) { 
    28         echo '<p>Oops '.$pop3->ERROR.'</p></div>'; 
    29         $pop3->reset(); 
    30         exit; 
    31     } else { 
    32         echo "<p>Mission complete, message <strong>$i</strong> deleted.</p>"; 
    33     } 
    3426 
    3527    $content = ''; 
     
    145137    $post_ID = wp_insert_post($post_data); 
    146138 
     139    if (!$post_ID) { 
     140        // we couldn't post, for whatever reason. better move forward to the next email 
     141        continue; 
     142    } 
     143 
    147144    do_action('publish_phone', $post_ID); 
    148145 
     
    153150    if (!$post_categories) $post_categories[] = 1; 
    154151    foreach ($post_categories as $post_category) : 
    155     $post_category = intval($post_category); 
     152       $post_category = intval($post_category); 
    156153 
    157     // Double check it's not there already 
    158     $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category"); 
     154       // Double check it's not there already 
     155       $exists = $wpdb->get_row("SELECT * FROM $wpdb->post2cat WHERE post_id = $post_ID AND category_id = $post_category"); 
    159156 
    160      if (!$exists && $result) {  
    161         $wpdb->query(" 
    162         INSERT INTO $wpdb->post2cat 
    163         (post_id, category_id) 
    164         VALUES 
    165         ($post_ID, $post_category) 
    166         "); 
     157        if (!$exists && $result) {  
     158            $wpdb->query(" 
     159            INSERT INTO $wpdb->post2cat 
     160            (post_id, category_id) 
     161            VALUES 
     162            ($post_ID, $post_category) 
     163            "); 
     164        } 
     165    endforeach; 
     166 
     167    if(!$pop3->delete($i)) { 
     168        echo '<p>Oops '.$pop3->ERROR.'</p></div>'; 
     169        $pop3->reset(); 
     170        exit; 
     171    } else { 
     172        echo "<p>Mission complete, message <strong>$i</strong> deleted.</p>"; 
    167173    } 
    168 endforeach; 
    169174 
    170175endfor;