Skip to content

Commit eda7d43

Browse files
committed
Deprecate get_userdatabylogin() and get_user_by_email(). Props scribu. fixes #18333
git-svn-id: https://develop.svn.wordpress.org/trunk@18513 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 15507ec commit eda7d43

8 files changed

Lines changed: 46 additions & 40 deletions

File tree

wp-admin/includes/schema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
645645
if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) )
646646
$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
647647

648-
$site_user = get_user_by_email( $email );
648+
$site_user = get_user_by( 'email', $email );
649649
if ( ! is_email( $email ) )
650650
$errors->add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) );
651651

wp-includes/capabilities.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ function __construct( $id, $name = '', $blog_id = '' ) {
447447
if ( ! empty( $id ) )
448448
$this->data = get_userdata( $id );
449449
else
450-
$this->data = get_userdatabylogin( $name );
450+
$this->data = get_user_by('login', $name );
451451

452452
if ( empty( $this->data->ID ) )
453453
return;

wp-includes/pluggable-deprecated.php

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,40 @@ function set_current_user($id, $name = '') {
3636
}
3737
endif;
3838

39+
if ( !function_exists('get_userdatabylogin') ) :
40+
/**
41+
* Retrieve user info by login name.
42+
*
43+
* @since 0.71
44+
* @deprecated 2.5
45+
* @deprecated Use get_user_by('login')
46+
*
47+
* @param string $user_login User's username
48+
* @return bool|object False on failure, User DB row object
49+
*/
50+
function get_userdatabylogin($user_login) {
51+
_deprecated_function( __FUNCTION__, '3.3', "get_user_by('login')" );
52+
return get_user_by('login', $user_login);
53+
}
54+
endif;
55+
56+
if ( !function_exists('get_user_by_email') ) :
57+
/**
58+
* Retrieve user info by email.
59+
*
60+
* @since 2.5
61+
* @deprecated 2.5
62+
* @deprecated Use get_user_by('email')
63+
*
64+
* @param string $email User's email address
65+
* @return bool|object False on failure, User DB row object
66+
*/
67+
function get_user_by_email($email) {
68+
_deprecated_function( __FUNCTION__, '3.3', "get_user_by('email')" );
69+
return get_user_by('email', $email);
70+
}
71+
endif;
72+
3973
if ( !function_exists('wp_setcookie') ) :
4074
/**
4175
* Sets a cookie for a user who just logged in. This function is deprecated.
@@ -54,7 +88,7 @@ function set_current_user($id, $name = '') {
5488
*/
5589
function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
5690
_deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' );
57-
$user = get_userdatabylogin($username);
91+
$user = get_user_by('login', $username);
5892
wp_set_auth_cookie($user->ID, $remember);
5993
}
6094
else :
@@ -133,4 +167,4 @@ function wp_login($username, $password, $deprecated = '') {
133167
}
134168
else :
135169
_deprecated_function( 'wp_login', '2.5', 'wp_signon()' );
136-
endif;
170+
endif;

wp-includes/pluggable.php

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -202,34 +202,6 @@ function get_user_by($field, $value) {
202202
}
203203
endif;
204204

205-
if ( !function_exists('get_userdatabylogin') ) :
206-
/**
207-
* Retrieve user info by login name.
208-
*
209-
* @since 0.71
210-
*
211-
* @param string $user_login User's username
212-
* @return bool|object False on failure, User DB row object
213-
*/
214-
function get_userdatabylogin($user_login) {
215-
return get_user_by('login', $user_login);
216-
}
217-
endif;
218-
219-
if ( !function_exists('get_user_by_email') ) :
220-
/**
221-
* Retrieve user info by email.
222-
*
223-
* @since 2.5
224-
*
225-
* @param string $email User's email address
226-
* @return bool|object False on failure, User DB row object
227-
*/
228-
function get_user_by_email($email) {
229-
return get_user_by('email', $email);
230-
}
231-
endif;
232-
233205
if ( !function_exists( 'wp_mail' ) ) :
234206
/**
235207
* Send mail, similar to PHP's mail
@@ -594,7 +566,7 @@ function wp_validate_auth_cookie($cookie = '', $scheme = '') {
594566
return false;
595567
}
596568

597-
$user = get_userdatabylogin($username);
569+
$user = get_user_by('login', $username);
598570
if ( ! $user ) {
599571
do_action('auth_cookie_bad_username', $cookie_elements);
600572
return false;

wp-includes/post.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3395,7 +3395,7 @@ function &get_pages($args = '') {
33953395
foreach ( $post_authors as $post_author ) {
33963396
//Do we have an author id or an author login?
33973397
if ( 0 == intval($post_author) ) {
3398-
$post_author = get_userdatabylogin($post_author);
3398+
$post_author = get_user_by('login', $post_author);
33993399
if ( empty($post_author) )
34003400
continue;
34013401
if ( empty($post_author->ID) )

wp-includes/user.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,7 @@ function clean_user_cache($id) {
12961296
* @return null|int The user's ID on success, and null on failure.
12971297
*/
12981298
function username_exists( $username ) {
1299-
if ( $user = get_userdatabylogin( $username ) ) {
1299+
if ( $user = get_user_by('login', $username ) ) {
13001300
return $user->ID;
13011301
} else {
13021302
return null;
@@ -1313,7 +1313,7 @@ function username_exists( $username ) {
13131313
* @return bool|int The user's ID on success, and false on failure.
13141314
*/
13151315
function email_exists( $email ) {
1316-
if ( $user = get_user_by_email($email) )
1316+
if ( $user = get_user_by('email', $email) )
13171317
return $user->ID;
13181318

13191319
return false;

wp-login.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ function retrieve_password() {
171171
$errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.'));
172172

173173
if ( strpos($_POST['user_login'], '@') ) {
174-
$user_data = get_user_by_email(trim($_POST['user_login']));
174+
$user_data = get_user_by('email', trim($_POST['user_login']));
175175
if ( empty($user_data) )
176176
$errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
177177
} else {
178178
$login = trim($_POST['user_login']);
179-
$user_data = get_userdatabylogin($login);
179+
$user_data = get_user_by('login', $login);
180180
}
181181

182182
do_action('lostpassword_post');
@@ -544,7 +544,7 @@ function register_new_user( $user_login, $user_email ) {
544544
// If the user wants ssl but the session is not ssl, force a secure cookie.
545545
if ( !empty($_POST['log']) && !force_ssl_admin() ) {
546546
$user_name = sanitize_user($_POST['log']);
547-
if ( $user = get_userdatabylogin($user_name) ) {
547+
if ( $user = get_user_by('login', $user_name) ) {
548548
if ( get_user_option('use_ssl', $user->ID) ) {
549549
$secure_cookie = true;
550550
force_ssl_admin(true);

wp-mail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
$author = sanitize_email($author);
114114
if ( is_email($author) ) {
115115
echo '<p>' . sprintf(__('Author is %s'), $author) . '</p>';
116-
$userdata = get_user_by_email($author);
116+
$userdata = get_user_by('email', $author);
117117
if ( empty($userdata) ) {
118118
$author_found = false;
119119
} else {

0 commit comments

Comments
 (0)