From 04bca9732b079104318c87cc956a19ee39703212 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 23 Dec 2015 04:46:28 +0000 Subject: [PATCH] Users: When determining whether to show the reassign content option during user delete, don't rely upon `WP_Query` as it doesn't return all forms of content `wp_delete_user()` operates on. This restores the reassign form when a user has a non-public post type or links assigned to them. Props swissspidy & tharsheblows for initial patches. Fixes #34993 for trunk. Built from https://develop.svn.wordpress.org/trunk@36068 git-svn-id: http://core.svn.wordpress.org/trunk@36033 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/users.php | 15 ++++++++------- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/wp-admin/users.php b/wp-admin/users.php index 44d860ecfa..e02c3943e8 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -211,13 +211,14 @@ case 'delete': else $userids = array_map( 'intval', (array) $_REQUEST['users'] ); - $users_posts = new WP_Query( array( - 'post_type' => 'any', - 'author' => implode( ',', $userids ), - 'posts_per_page' => 1 - ) ); + $users_have_content = false; + if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) { + $users_have_content = true; + } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) { + $users_have_content = true; + } - if ( $users_posts->have_posts() ) { + if ( $users_have_content ) { add_action( 'admin_head', 'delete_users_add_js' ); } @@ -257,7 +258,7 @@ case 'delete': have_posts() ) : ?> + if ( ! $users_have_content ) : ?> diff --git a/wp-includes/version.php b/wp-includes/version.php index 2c7b8678da..2ffef1a3a2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-36062'; +$wp_version = '4.5-alpha-36068'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.