Add missing doc blocks to `user.php`.

`username_exists()` should return `false` instead of `null`, just like `email_exists()` does, which is right under it.

See #32444.

Built from https://develop.svn.wordpress.org/trunk@32637


git-svn-id: http://core.svn.wordpress.org/trunk@32607 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-05-28 15:51:25 +00:00
parent abfece527b
commit d38fed6449
2 changed files with 59 additions and 45 deletions

View File

@ -19,6 +19,8 @@
*
* @since 2.5.0
*
* @global string $auth_secure_cookie
*
* @param array $credentials Optional. User info in order to sign on.
* @param string|bool $secure_cookie Optional. Whether to use secure cookie.
* @return WP_User|WP_Error WP_User on success, WP_Error on failure.
@ -161,6 +163,8 @@ function wp_authenticate_username_password($user, $username, $password) {
*
* @since 2.8.0
*
* @global string $auth_secure_cookie
*
* @param WP_User|WP_Error|null $user WP_User or WP_Error object from a previous callback. Default null.
* @param string $username Username. If not empty, cancels the cookie authentication.
* @param string $password Password. If not empty, cancels the cookie authentication.
@ -231,7 +235,7 @@ function wp_authenticate_spam_check( $user ) {
*
* @param int|bool $user_id The user ID (or false) as received from the
* determine_current_user filter.
* @return int|bool User ID if validated, false otherwise. If a user ID from
* @return int|false User ID if validated, false otherwise. If a user ID from
* an earlier filter callback is received, that value is returned.
*/
function wp_validate_logged_in_cookie( $user_id ) {
@ -287,6 +291,8 @@ function count_user_posts( $userid, $post_type = 'post', $public_only = false )
*
* @since 3.0.0
*
* @global wpdb $wpdb
*
* @param array $users Array of user IDs.
* @param string|array $post_type Optional. Single post type or array of post types to check. Defaults to 'post'.
* @param bool $public_only Optional. Only return counts for public posts. Defaults to false.
@ -517,6 +523,9 @@ class WP_User_Query {
* for `$orderby` parameter.
* @access public
*
* @global wpdb $wpdb
* @global int $blog_id
*
* @param string|array $query {
* Optional. Array or string of Query parameters.
*
@ -901,10 +910,12 @@ class WP_User_Query {
* @access protected
* @since 3.1.0
*
* @global wpdb $wpdb
*
* @param string $string
* @param array $cols
* @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for
* single site. Single site allows leading and trailing wildcards, Network Admin only trailing.
* @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for single site.
* Single site allows leading and trailing wildcards, Network Admin only trailing.
* @return string
*/
protected function get_search_sql( $string, $cols, $wild = false ) {
@ -959,7 +970,7 @@ class WP_User_Query {
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $orderby Alias for the field to order by.
* @return string|bool Value to used in the ORDER clause, if `$orderby` is valid. False otherwise.
* @return string Value to used in the ORDER clause, if `$orderby` is valid.
*/
protected function parse_orderby( $orderby ) {
global $wpdb;
@ -1091,7 +1102,7 @@ class WP_User_Query {
*
* @param callable $name Method to call.
* @param array $arguments Arguments to pass when calling.
* @return mixed|bool Return value of the callback, false otherwise.
* @return mixed Return value of the callback, false otherwise.
*/
public function __call( $name, $arguments ) {
if ( 'get_search_sql' === $name ) {
@ -1261,7 +1272,7 @@ function is_user_member_of_blog( $user_id = 0, $blog_id = 0 ) {
* @param string $meta_key Metadata name.
* @param mixed $meta_value Metadata value.
* @param bool $unique Optional, default is false. Whether the same key should not be added.
* @return int|bool Meta ID on success, false on failure.
* @return int|false Meta ID on success, false on failure.
*/
function add_user_meta($user_id, $meta_key, $meta_value, $unique = false) {
return add_metadata('user', $user_id, $meta_key, $meta_value, $unique);
@ -1277,7 +1288,7 @@ function add_user_meta($user_id, $meta_key, $meta_value, $unique = false) {
* @since 3.0.0
* @link https://codex.wordpress.org/Function_Reference/delete_user_meta
*
* @param int $user_id user ID
* @param int $user_id User ID
* @param string $meta_key Metadata name.
* @param mixed $meta_value Optional. Metadata value.
* @return bool True on success, false on failure.
@ -1295,8 +1306,7 @@ function delete_user_meta($user_id, $meta_key, $meta_value = '') {
* @param int $user_id User ID.
* @param string $key Optional. The meta key to retrieve. By default, returns data for all keys.
* @param bool $single Whether to return a single value.
* @return mixed Will be an array if $single is false. Will be value of meta data field if $single
* is true.
* @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true.
*/
function get_user_meta($user_id, $key = '', $single = false) {
return get_metadata('user', $user_id, $key, $single);
@ -1332,6 +1342,9 @@ function update_user_meta($user_id, $meta_key, $meta_value, $prev_value = '') {
* Using $strategy = 'memory' this is memory-intensive and should handle around 10^5 users, but see WP Bug #12257.
*
* @since 3.0.0
*
* @global wpdb $wpdb
*
* @param string $strategy 'time' or 'memory'
* @return array Includes a grand total and an array of counts indexed by role strings.
*/
@ -1406,8 +1419,9 @@ function count_users($strategy = 'time') {
* Used by wp_set_current_user() for back compat. Might be deprecated in the future.
*
* @since 2.0.4
* @global string $userdata User description.
*
* @global string $user_login The user username for logging in
* @global object $userdata User data.
* @global int $user_level The level of the user
* @global int $user_ID The ID of the user
* @global string $user_email The email address of the user
@ -1453,6 +1467,7 @@ function setup_userdata($for_user_id = '') {
* @since 2.3.0
*
* @global wpdb $wpdb WordPress database object for queries.
* @global int $blog_id
*
* @param array|string $args {
* Optional. Array or string of arguments to generate a drop-down of users.
@ -1492,7 +1507,7 @@ function setup_userdata($for_user_id = '') {
* @type string $who Which type of users to query. Accepts only an empty string or
* 'authors'. Default empty.
* }
* @return string|null Null on display. String of HTML content on retrieve.
* @return string String of HTML content.
*/
function wp_dropdown_users( $args = '' ) {
$defaults = array(
@ -1583,7 +1598,7 @@ function wp_dropdown_users( $args = '' ) {
*
* @param string $field The user Object field name.
* @param mixed $value The user Object value.
* @param int $user_id user ID.
* @param int $user_id User ID.
* @param string $context How to sanitize user fields. Looks for 'raw', 'edit', 'db', 'display',
* 'attribute' and 'js'.
* @return mixed Sanitized value.
@ -1719,14 +1734,13 @@ function clean_user_cache( $user ) {
* @since 2.0.0
*
* @param string $username Username.
* @return null|int The user's ID on success, and null on failure.
* @return int|false The user's ID on success, and false on failure.
*/
function username_exists( $username ) {
if ( $user = get_user_by('login', $username ) ) {
if ( $user = get_user_by( 'login', $username ) ) {
return $user->ID;
} else {
return null;
}
return false;
}
/**
@ -1735,12 +1749,12 @@ function username_exists( $username ) {
* @since 2.1.0
*
* @param string $email Email.
* @return bool|int The user's ID on success, and false on failure.
* @return int|false 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;
}
@ -2148,7 +2162,7 @@ function wp_update_user($userdata) {
* @param string $username The user's username.
* @param string $password The user's password.
* @param string $email Optional. The user's email. Default empty.
* @return int The new user's ID.
* @return int|WP_Error The new user's ID.
*/
function wp_create_user($username, $password, $email = '') {
$user_login = wp_slash( $username );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.3-alpha-32636';
$wp_version = '4.3-alpha-32637';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.