Make WordPress Core


Ignore:
Timestamp:
04/28/2004 08:36:31 PM (22 years ago)
Author:
saxmatt
Message:

Don't delete everything if there are no posts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/users.php

    r1199 r1207  
    139139
    140140    $post_ids = $wpdb->get_col("SELECT ID FROM $tableposts WHERE post_author = $id");
    141     $post_ids = implode(',', $post_ids);
    142    
    143     // Delete comments, *backs
    144     $wpdb->query("DELETE FROM $tablecomments WHERE comment_post_ID IN ($post_ids)");
    145     // Clean cats
    146     $wpdb->query("DELETE FROM $tablepost2cat WHERE post_id IN ($post_ids)");
    147     // Clean post_meta
    148     $wpdb->query("DELETE FROM $tablepostmeta WHERE post_id IN ($post_ids)");
    149     // Clean links
    150     $wpdb->query("DELETE FROM $tablelinks WHERE link_owner = $id");
    151     // Delete posts
    152     $wpdb->query("DELETE FROM $tableposts WHERE post_author = $id");
    153     // FINALLY, delete user
    154     $wpdb->query("DELETE FROM $tableusers WHERE ID = $id");
    155    
     141    if ($post_ids) {
     142        $post_ids = implode(',', $post_ids);
     143       
     144        // Delete comments, *backs
     145        $wpdb->query("DELETE FROM $tablecomments WHERE comment_post_ID IN ($post_ids)");
     146        // Clean cats
     147        $wpdb->query("DELETE FROM $tablepost2cat WHERE post_id IN ($post_ids)");
     148        // Clean post_meta
     149        $wpdb->query("DELETE FROM $tablepostmeta WHERE post_id IN ($post_ids)");
     150        // Clean links
     151        $wpdb->query("DELETE FROM $tablelinks WHERE link_owner = $id");
     152        // Delete posts
     153        $wpdb->query("DELETE FROM $tableposts WHERE post_author = $id");
     154        // FINALLY, delete user
     155        $wpdb->query("DELETE FROM $tableusers WHERE ID = $id");
     156    }
    156157    header('Location: users.php?deleted=true');
    157158
Note: See TracChangeset for help on using the changeset viewer.