<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[18513] trunk: Deprecate get_userdatabylogin() and get_user_by_email().</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/18513">18513</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2011-08-05 16:57:31 +0000 (Fri, 05 Aug 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Deprecate get_userdatabylogin() and get_user_by_email(). Props scribu. fixes <a href="http://core.trac.wordpress.org/ticket/18333">#18333</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesschemaphp">trunk/wp-admin/includes/schema.php</a></li>
<li><a href="#trunkwpincludescapabilitiesphp">trunk/wp-includes/capabilities.php</a></li>
<li><a href="#trunkwpincludespluggabledeprecatedphp">trunk/wp-includes/pluggable-deprecated.php</a></li>
<li><a href="#trunkwpincludespluggablephp">trunk/wp-includes/pluggable.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
<li><a href="#trunkwpincludesuserphp">trunk/wp-includes/user.php</a></li>
<li><a href="#trunkwploginphp">trunk/wp-login.php</a></li>
<li><a href="#trunkwpmailphp">trunk/wp-mail.php</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#trunk">trunk/</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunk"></a>
<div class="propset"><h4>Property changes: trunk</h4>
<pre class="diff"><span>
</span></pre></div>
<a id="svnmergeinfo"></a>
<div class="modfile"><h4>Modified: svn:mergeinfo</h4></div>
<span class="cx">   + /branches/3.1:18031
</span><span class="cx">/trunk:18512
</span><a id="trunkwpadminincludesschemaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/schema.php (18512 => 18513)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/schema.php        2011-08-05 16:45:11 UTC (rev 18512)
+++ trunk/wp-admin/includes/schema.php        2011-08-05 16:57:31 UTC (rev 18513)
</span><span class="lines">@@ -645,7 +645,7 @@
</span><span class="cx">         if ( $network_id == $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT id FROM $wpdb-&gt;site WHERE id = %d&quot;, $network_id ) ) )
</span><span class="cx">                 $errors-&gt;add( 'siteid_exists', __( 'The network already exists.' ) );
</span><span class="cx"> 
</span><del>-        $site_user = get_user_by_email( $email );
</del><ins>+        $site_user = get_user_by( 'email', $email );
</ins><span class="cx">         if ( ! is_email( $email ) )
</span><span class="cx">                 $errors-&gt;add( 'invalid_email', __( 'You must provide a valid e-mail address.' ) );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludescapabilitiesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/capabilities.php (18512 => 18513)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/capabilities.php        2011-08-05 16:45:11 UTC (rev 18512)
+++ trunk/wp-includes/capabilities.php        2011-08-05 16:57:31 UTC (rev 18513)
</span><span class="lines">@@ -447,7 +447,7 @@
</span><span class="cx">                 if ( ! empty( $id ) )
</span><span class="cx">                         $this-&gt;data = get_userdata( $id );
</span><span class="cx">                 else
</span><del>-                        $this-&gt;data = get_userdatabylogin( $name );
</del><ins>+                        $this-&gt;data = get_user_by('login', $name );
</ins><span class="cx"> 
</span><span class="cx">                 if ( empty( $this-&gt;data-&gt;ID ) )
</span><span class="cx">                         return;
</span></span></pre></div>
<a id="trunkwpincludespluggabledeprecatedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pluggable-deprecated.php (18512 => 18513)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pluggable-deprecated.php        2011-08-05 16:45:11 UTC (rev 18512)
+++ trunk/wp-includes/pluggable-deprecated.php        2011-08-05 16:57:31 UTC (rev 18513)
</span><span class="lines">@@ -36,6 +36,40 @@
</span><span class="cx"> }
</span><span class="cx"> endif;
</span><span class="cx"> 
</span><ins>+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', &quot;get_user_by('login')&quot; );
+        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', &quot;get_user_by('email')&quot; );
+        return get_user_by('email', $email);
+}
+endif;
+
</ins><span class="cx"> if ( !function_exists('wp_setcookie') ) :
</span><span class="cx"> /**
</span><span class="cx">  * Sets a cookie for a user who just logged in. This function is deprecated.
</span><span class="lines">@@ -54,7 +88,7 @@
</span><span class="cx">  */
</span><span class="cx"> function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) {
</span><span class="cx">         _deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' );
</span><del>-        $user = get_userdatabylogin($username);
</del><ins>+        $user = get_user_by('login', $username);
</ins><span class="cx">         wp_set_auth_cookie($user-&gt;ID, $remember);
</span><span class="cx"> }
</span><span class="cx"> else :
</span><span class="lines">@@ -133,4 +167,4 @@
</span><span class="cx"> }
</span><span class="cx"> else :
</span><span class="cx">         _deprecated_function( 'wp_login', '2.5', 'wp_signon()' );
</span><del>-endif;
</del><span class="cx">\ No newline at end of file
</span><ins>+endif;
</ins></span></pre></div>
<a id="trunkwpincludespluggablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pluggable.php (18512 => 18513)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pluggable.php        2011-08-05 16:45:11 UTC (rev 18512)
+++ trunk/wp-includes/pluggable.php        2011-08-05 16:57:31 UTC (rev 18513)
</span><span class="lines">@@ -202,34 +202,6 @@
</span><span class="cx"> }
</span><span class="cx"> endif;
</span><span class="cx"> 
</span><del>-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;
-
</del><span class="cx"> if ( !function_exists( 'wp_mail' ) ) :
</span><span class="cx"> /**
</span><span class="cx">  * Send mail, similar to PHP's mail
</span><span class="lines">@@ -594,7 +566,7 @@
</span><span class="cx">                 return false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        $user = get_userdatabylogin($username);
</del><ins>+        $user = get_user_by('login', $username);
</ins><span class="cx">         if ( ! $user ) {
</span><span class="cx">                 do_action('auth_cookie_bad_username', $cookie_elements);
</span><span class="cx">                 return false;
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (18512 => 18513)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2011-08-05 16:45:11 UTC (rev 18512)
+++ trunk/wp-includes/post.php        2011-08-05 16:57:31 UTC (rev 18513)
</span><span class="lines">@@ -3395,7 +3395,7 @@
</span><span class="cx">                         foreach ( $post_authors as $post_author ) {
</span><span class="cx">                                 //Do we have an author id or an author login?
</span><span class="cx">                                 if ( 0 == intval($post_author) ) {
</span><del>-                                        $post_author = get_userdatabylogin($post_author);
</del><ins>+                                        $post_author = get_user_by('login', $post_author);
</ins><span class="cx">                                         if ( empty($post_author) )
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         if ( empty($post_author-&gt;ID) )
</span></span></pre></div>
<a id="trunkwpincludesuserphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/user.php (18512 => 18513)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/user.php        2011-08-05 16:45:11 UTC (rev 18512)
+++ trunk/wp-includes/user.php        2011-08-05 16:57:31 UTC (rev 18513)
</span><span class="lines">@@ -1296,7 +1296,7 @@
</span><span class="cx">  * @return null|int The user's ID on success, and null on failure.
</span><span class="cx">  */
</span><span class="cx"> function username_exists( $username ) {
</span><del>-        if ( $user = get_userdatabylogin( $username ) ) {
</del><ins>+        if ( $user = get_user_by('login', $username ) ) {
</ins><span class="cx">                 return $user-&gt;ID;
</span><span class="cx">         } else {
</span><span class="cx">                 return null;
</span><span class="lines">@@ -1313,7 +1313,7 @@
</span><span class="cx">  * @return bool|int The user's ID on success, and false on failure.
</span><span class="cx">  */
</span><span class="cx"> function email_exists( $email ) {
</span><del>-        if ( $user = get_user_by_email($email) )
</del><ins>+        if ( $user = get_user_by('email', $email) )
</ins><span class="cx">                 return $user-&gt;ID;
</span><span class="cx"> 
</span><span class="cx">         return false;
</span></span></pre></div>
<a id="trunkwploginphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-login.php (18512 => 18513)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-login.php        2011-08-05 16:45:11 UTC (rev 18512)
+++ trunk/wp-login.php        2011-08-05 16:57:31 UTC (rev 18513)
</span><span class="lines">@@ -171,12 +171,12 @@
</span><span class="cx">                 $errors-&gt;add('empty_username', __('&lt;strong&gt;ERROR&lt;/strong&gt;: Enter a username or e-mail address.'));
</span><span class="cx"> 
</span><span class="cx">         if ( strpos($_POST['user_login'], '@') ) {
</span><del>-                $user_data = get_user_by_email(trim($_POST['user_login']));
</del><ins>+                $user_data = get_user_by('email', trim($_POST['user_login']));
</ins><span class="cx">                 if ( empty($user_data) )
</span><span class="cx">                         $errors-&gt;add('invalid_email', __('&lt;strong&gt;ERROR&lt;/strong&gt;: There is no user registered with that email address.'));
</span><span class="cx">         } else {
</span><span class="cx">                 $login = trim($_POST['user_login']);
</span><del>-                $user_data = get_userdatabylogin($login);
</del><ins>+                $user_data = get_user_by('login', $login);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         do_action('lostpassword_post');
</span><span class="lines">@@ -544,7 +544,7 @@
</span><span class="cx">         // If the user wants ssl but the session is not ssl, force a secure cookie.
</span><span class="cx">         if ( !empty($_POST['log']) &amp;&amp; !force_ssl_admin() ) {
</span><span class="cx">                 $user_name = sanitize_user($_POST['log']);
</span><del>-                if ( $user = get_userdatabylogin($user_name) ) {
</del><ins>+                if ( $user = get_user_by('login', $user_name) ) {
</ins><span class="cx">                         if ( get_user_option('use_ssl', $user-&gt;ID) ) {
</span><span class="cx">                                 $secure_cookie = true;
</span><span class="cx">                                 force_ssl_admin(true);
</span></span></pre></div>
<a id="trunkwpmailphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-mail.php (18512 => 18513)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-mail.php        2011-08-05 16:45:11 UTC (rev 18512)
+++ trunk/wp-mail.php        2011-08-05 16:57:31 UTC (rev 18513)
</span><span class="lines">@@ -113,7 +113,7 @@
</span><span class="cx">                                 $author = sanitize_email($author);
</span><span class="cx">                                 if ( is_email($author) ) {
</span><span class="cx">                                         echo '&lt;p&gt;' . sprintf(__('Author is %s'), $author) . '&lt;/p&gt;';
</span><del>-                                        $userdata = get_user_by_email($author);
</del><ins>+                                        $userdata = get_user_by('email', $author);
</ins><span class="cx">                                         if ( empty($userdata) ) {
</span><span class="cx">                                                 $author_found = false;
</span><span class="cx">                                         } else {
</span></span></pre>
</div>
</div>

</body>
</html>