[wp-trac] [WordPress Trac] #20460: Notice with clean_user_cache when deleting a user
WordPress Trac
wp-trac at lists.automattic.com
Mon Apr 16 20:18:54 UTC 2012
#20460: Notice with clean_user_cache when deleting a user
--------------------------+-----------------------------
Reporter: blueyed | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Multisite | Version: 3.4
Severity: minor | Keywords: has-patch
--------------------------+-----------------------------
I just got the following error when deleting a user in a network setup
site / multisite setup:
{{{
Notice: Trying to get property of non-object in /srv/wordpress/wp-
includes/user.php on line 1152
Call Stack:
0.0000 342776 1. {main}() /srv/wordpress/wp-
admin/network/users.php:0
0.1137 3522036 2. wpmu_delete_user() /srv/wordpress/wp-
admin/network/users.php:201
0.1278 3528060 3. clean_user_cache() /srv/wordpress/wp-
admin/includes/ms.php:165
}}}
This can happen when {{{$user = WP_User::get_data_by( 'id', $id );}}} is
"false".
The patch appears to be trivial, so I am attaching it inline:
{{{
diff --git i/wp-includes/user.php w/wp-includes/user.php
index 463f311..8d99dd5 100644
--- i/wp-includes/user.php
+++ w/wp-includes/user.php
@@ -1149,9 +1149,11 @@ function clean_user_cache($id) {
$user = WP_User::get_data_by( 'id', $id );
wp_cache_delete($id, 'users');
- wp_cache_delete($user->user_login, 'userlogins');
- wp_cache_delete($user->user_email, 'useremail');
- wp_cache_delete($user->user_nicename, 'userslugs');
+ if ( is_object($user) ) {
+ wp_cache_delete($user->user_login, 'userlogins');
+ wp_cache_delete($user->user_email, 'useremail');
+ wp_cache_delete($user->user_nicename, 'userslugs');
+ }
}
/**
}}}
Apart from that I suggest the following documentation fix:
{{{
diff --git i/wp-includes/capabilities.php w/wp-includes/capabilities.php
index 19568e5..481edd8 100644
--- i/wp-includes/capabilities.php
+++ w/wp-includes/capabilities.php
@@ -482,7 +482,7 @@ class WP_User {
*
* @param string $field The field to query against: 'id', 'slug',
'email' or 'login'
* @param string|int $value The field value
- * @return object Raw user object
+ * @return object|boolean Raw user object, false on error.
*/
static function get_data_by( $field, $value ) {
global $wpdb;
}}}
I am using WP trunk (via the Github mirror).
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20460>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list