From ec4ccf2900d791efda282b0675486523ab02f8b6 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 5 Aug 2011 16:57:31 +0000 Subject: [PATCH] Deprecate get_userdatabylogin() and get_user_by_email(). Props scribu. fixes #18333 git-svn-id: http://svn.automattic.com/wordpress/trunk@18513 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/schema.php | 2 +- wp-includes/capabilities.php | 2 +- wp-includes/pluggable-deprecated.php | 38 ++++++++++++++++++++++++++-- wp-includes/pluggable.php | 30 +--------------------- wp-includes/post.php | 2 +- wp-includes/user.php | 4 +-- wp-login.php | 6 ++--- wp-mail.php | 2 +- 8 files changed, 46 insertions(+), 40 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 1834153e88..acf3b806c6 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -645,7 +645,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) $errors->add( 'siteid_exists', __( 'The network already exists.' ) ); - $site_user = get_user_by_email( $email ); + $site_user = get_user_by( 'email', $email ); if ( ! is_email( $email ) ) $errors->add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) ); diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index eba1df3e2b..554f5be79c 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -447,7 +447,7 @@ class WP_User { if ( ! empty( $id ) ) $this->data = get_userdata( $id ); else - $this->data = get_userdatabylogin( $name ); + $this->data = get_user_by('login', $name ); if ( empty( $this->data->ID ) ) return; diff --git a/wp-includes/pluggable-deprecated.php b/wp-includes/pluggable-deprecated.php index bb0e4f0eb0..e10fded09c 100644 --- a/wp-includes/pluggable-deprecated.php +++ b/wp-includes/pluggable-deprecated.php @@ -36,6 +36,40 @@ function set_current_user($id, $name = '') { } endif; +if ( !function_exists('get_userdatabylogin') ) : +/** + * Retrieve user info by login name. + * + * @since 0.71 + * @deprecated 2.5 + * @deprecated Use get_user_by('login') + * + * @param string $user_login User's username + * @return bool|object False on failure, User DB row object + */ +function get_userdatabylogin($user_login) { + _deprecated_function( __FUNCTION__, '3.3', "get_user_by('login')" ); + return get_user_by('login', $user_login); +} +endif; + +if ( !function_exists('get_user_by_email') ) : +/** + * Retrieve user info by email. + * + * @since 2.5 + * @deprecated 2.5 + * @deprecated Use get_user_by('email') + * + * @param string $email User's email address + * @return bool|object False on failure, User DB row object + */ +function get_user_by_email($email) { + _deprecated_function( __FUNCTION__, '3.3', "get_user_by('email')" ); + return get_user_by('email', $email); +} +endif; + if ( !function_exists('wp_setcookie') ) : /** * Sets a cookie for a user who just logged in. This function is deprecated. @@ -54,7 +88,7 @@ if ( !function_exists('wp_setcookie') ) : */ function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) { _deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' ); - $user = get_userdatabylogin($username); + $user = get_user_by('login', $username); wp_set_auth_cookie($user->ID, $remember); } else : @@ -133,4 +167,4 @@ function wp_login($username, $password, $deprecated = '') { } else : _deprecated_function( 'wp_login', '2.5', 'wp_signon()' ); -endif; \ No newline at end of file +endif; diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 4137ebaf1b..fab5d41b94 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -202,34 +202,6 @@ function get_user_by($field, $value) { } endif; -if ( !function_exists('get_userdatabylogin') ) : -/** - * Retrieve user info by login name. - * - * @since 0.71 - * - * @param string $user_login User's username - * @return bool|object False on failure, User DB row object - */ -function get_userdatabylogin($user_login) { - return get_user_by('login', $user_login); -} -endif; - -if ( !function_exists('get_user_by_email') ) : -/** - * Retrieve user info by email. - * - * @since 2.5 - * - * @param string $email User's email address - * @return bool|object False on failure, User DB row object - */ -function get_user_by_email($email) { - return get_user_by('email', $email); -} -endif; - if ( !function_exists( 'wp_mail' ) ) : /** * Send mail, similar to PHP's mail @@ -594,7 +566,7 @@ function wp_validate_auth_cookie($cookie = '', $scheme = '') { return false; } - $user = get_userdatabylogin($username); + $user = get_user_by('login', $username); if ( ! $user ) { do_action('auth_cookie_bad_username', $cookie_elements); return false; diff --git a/wp-includes/post.php b/wp-includes/post.php index 5e874b9cb6..391818b666 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3395,7 +3395,7 @@ function &get_pages($args = '') { foreach ( $post_authors as $post_author ) { //Do we have an author id or an author login? if ( 0 == intval($post_author) ) { - $post_author = get_userdatabylogin($post_author); + $post_author = get_user_by('login', $post_author); if ( empty($post_author) ) continue; if ( empty($post_author->ID) ) diff --git a/wp-includes/user.php b/wp-includes/user.php index b7f49f564f..68b2704003 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -1296,7 +1296,7 @@ function clean_user_cache($id) { * @return null|int The user's ID on success, and null on failure. */ function username_exists( $username ) { - if ( $user = get_userdatabylogin( $username ) ) { + if ( $user = get_user_by('login', $username ) ) { return $user->ID; } else { return null; @@ -1313,7 +1313,7 @@ function username_exists( $username ) { * @return bool|int The user's ID on success, and false on failure. */ function email_exists( $email ) { - if ( $user = get_user_by_email($email) ) + if ( $user = get_user_by('email', $email) ) return $user->ID; return false; diff --git a/wp-login.php b/wp-login.php index 76788f17b2..60640c2500 100644 --- a/wp-login.php +++ b/wp-login.php @@ -171,12 +171,12 @@ function retrieve_password() { $errors->add('empty_username', __('ERROR: Enter a username or e-mail address.')); if ( strpos($_POST['user_login'], '@') ) { - $user_data = get_user_by_email(trim($_POST['user_login'])); + $user_data = get_user_by('email', trim($_POST['user_login'])); if ( empty($user_data) ) $errors->add('invalid_email', __('ERROR: There is no user registered with that email address.')); } else { $login = trim($_POST['user_login']); - $user_data = get_userdatabylogin($login); + $user_data = get_user_by('login', $login); } do_action('lostpassword_post'); @@ -544,7 +544,7 @@ default: // If the user wants ssl but the session is not ssl, force a secure cookie. if ( !empty($_POST['log']) && !force_ssl_admin() ) { $user_name = sanitize_user($_POST['log']); - if ( $user = get_userdatabylogin($user_name) ) { + if ( $user = get_user_by('login', $user_name) ) { if ( get_user_option('use_ssl', $user->ID) ) { $secure_cookie = true; force_ssl_admin(true); diff --git a/wp-mail.php b/wp-mail.php index 69b54156eb..4ecc9548ef 100644 --- a/wp-mail.php +++ b/wp-mail.php @@ -113,7 +113,7 @@ for ( $i = 1; $i <= $count; $i++ ) { $author = sanitize_email($author); if ( is_email($author) ) { echo '

' . sprintf(__('Author is %s'), $author) . '

'; - $userdata = get_user_by_email($author); + $userdata = get_user_by('email', $author); if ( empty($userdata) ) { $author_found = false; } else {