From 41f3ab73ff312047f6add762da37c6f2b0f40ed5 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 27 Dec 2012 15:36:08 +0000 Subject: [PATCH] Return WP_Error from wp_update_user() on a non-existent user, avoiding a fatal error in the process. props n7studios, SergeyBiryukov. fixes #22858 for trunk. Unit tests: [11776/tests]. git-svn-id: https://develop.svn.wordpress.org/trunk@23210 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/user.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wp-includes/user.php b/wp-includes/user.php index 7bdc37cc76..56e6d082a5 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -1452,6 +1452,8 @@ function wp_update_user($userdata) { // First, get all of the original fields $user_obj = get_userdata( $ID ); + if ( ! $user_obj ) + return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) ); $user = $user_obj->to_array();