Exclusion instead of inclusion for post types for lost attachment scan. Exclude attachments and any !public types, and don't consider attachments on unregistered post types to be lost. fixes #10911.

git-svn-id: http://svn.automattic.com/wordpress/trunk@14789 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-05-21 19:23:52 +00:00
parent 8d4a9a7568
commit a3dfa293d0
1 changed files with 1 additions and 1 deletions

View File

@ -20,7 +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 IN ('" . join("', '", get_post_types() ) . "')"));
$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)");
$_GET['detached'] = 1;