Ticket #10911: 10911.2.diff
File 10911.2.diff, 871 bytes (added by , 15 years ago) |
---|
-
wp-admin/upload.php
20 20 if ( !current_user_can('edit_posts') ) 21 21 wp_die( __('You are not allowed to scan for lost attachments.') ); 22 22 23 $all_posts = implode(',', $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type IN ('post', 'page')")); 24 $lost = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent > '0' and post_parent NOT IN ($all_posts)"); 25 23 $lost = $wpdb->get_col("SELECT att.ID FROM $wpdb->posts as att LEFT JOIN $wpdb->posts as post ON att.post_parent = post.ID WHERE att.post_parent > 0 AND att.post_type = 'attachment' and post.ID IS NULL"); 26 24 $_GET['detached'] = 1; 27 25 28 26 } elseif ( isset($_GET['found_post_id']) && isset($_GET['media']) ) {