From e24b34626373163f54bad18f8d7646ec664da906 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 22 May 2010 23:05:35 +0000 Subject: [PATCH] Use subquery when finding detached objects. Props filosofo. fixes #13496 git-svn-id: https://develop.svn.wordpress.org/trunk@14808 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/upload.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 3586051d4f..a9d0b97dcb 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -20,8 +20,7 @@ if ( isset($_GET['find_detached']) ) { if ( !current_user_can('edit_posts') ) wp_die( __('You are not allowed to scan for lost attachments.') ); - $all_posts = implode( ',', $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type NOT IN ('attachment', '" . join("', '", get_post_types( array( 'public' => false ) ) ) . "')" ) ); - $lost = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent > '0' and post_parent NOT IN ($all_posts)"); + $lost = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent > '0' and post_parent NOT IN ( SELECT ID FROM $wpdb->posts WHERE post_type NOT IN ('attachment', '" . join("', '", get_post_types( array( 'public' => false ) ) ) . "') )"); $_GET['detached'] = 1;