Make WordPress Core

Ticket #31588: 31588.patch

File 31588.patch, 6.3 KB (added by dlh, 9 years ago)
  • src/wp-includes/user.php

     
    17661766}
    17671767
    17681768/**
    1769  * Insert an user into the database.
     1769 * Insert a user into the database.
    17701770 *
    1771  * Most of the $userdata array fields have filters associated with the values.
    1772  * The exceptions are 'rich_editing', 'role', 'jabber', 'aim', 'yim',
    1773  * 'user_registered', and 'ID'. The filters have the prefix 'pre_user_' followed
    1774  * by the field name. An example using 'description' would have the filter
    1775  * called, 'pre_user_description' that can be hooked into.
     1771 * Some `$userdata` fields also have 'pre_user_' filters associated with the values.
    17761772 *
    17771773 * @since 2.0.0
     1774 * @since 3.6.0 The `aim`, `jabber`, and `yim` fields were removed as default user contact
     1775 *              methods for new installs. See {@see wp_get_user_contact_methods()}.
    17781776 *
    17791777 * @global wpdb $wpdb WordPress database object for queries.
    17801778 *
    17811779 * @param array $userdata {
    17821780 *     An array, object, or WP_User object of user data arguments.
    17831781 *
    1784  *     @type int         $ID              User ID. If supplied, the user will be updated.
    1785  *     @type string      $user_pass       The plain-text user password.
    1786  *     @type string      $user_login      The user's login username.
    1787  *     @type string      $user_nicename   The URL-friendly user name.
    1788  *     @type string      $user_url        The user URL.
    1789  *     @type string      $user_email      The user email address.
    1790  *     @type string      $display_name    The user's display name.
    1791  *                                        Default is the the user's username.
    1792  *     @type string      $nickname        The user's nickname. Default
    1793  *                                        Default is the the user's username.
    1794  *     @type string      $first_name      The user's first name. For new users, will be used
    1795  *                                        to build $display_name if unspecified.
    1796  *     @type stirng      $last_name       The user's last name. For new users, will be used
    1797  *                                        to build $display_name if unspecified.
    1798  *     @type string|bool $rich_editing    Whether to enable the rich-editor for the user. False
    1799  *                                        if not empty.
    1800  *     @type string      $user_registered Date the user registered. Format is 'Y-m-d H:i:s'.
    1801  *     @type string      $role            User's role.
    1802  *     @type string      $jabber          User's Jabber account username.
    1803  *     @type string      $aim             User's AIM account username.
    1804  *     @type string      $yim             User's Yahoo! messenger username.
     1782 *     @type int         $ID                   User ID. If supplied, the user will be updated.
     1783 *     @type string      $user_pass            The plain-text user password.
     1784 *     @type string      $user_login           The user's login username.
     1785 *     @type string      $user_nicename        The URL-friendly user name.
     1786 *     @type string      $user_url             The user URL.
     1787 *     @type string      $user_email           The user email address.
     1788 *     @type string      $display_name         The user's display name.
     1789 *                                             Default is the the user's username.
     1790 *     @type string      $nickname             The user's nickname.
     1791 *                                             Default is the the user's username.
     1792 *     @type string      $first_name           The user's first name. For new users, will be used
     1793 *                                             to build the user's display name if `$display_name`
     1794 *                                             is not specified.
     1795 *     @type stirng      $last_name            The user's last name. For new users, will be used
     1796 *                                             to build the user's display name if `$display_name`
     1797 *                                             is not specified.
     1798 *     @type string      $description          The user's description.
     1799 *     @type string|bool $rich_editing         Whether to enable the rich-editor for the user.
     1800 *                                             False if not empty.
     1801 *     @type string|bool $comment_shortcuts    Whether to enable comment moderation keyboard shortcuts
     1802 *                                             for the user. Default false.
     1803 *     @type string      $admin_color          Admin color scheme for the user. Default 'fresh'.
     1804 *     @type bool        $use_ssl              Whether the user should always access the admin over
     1805 *                                             https. Default false.
     1806 *     @type string      $user_registered      Date the user registered. Format is 'Y-m-d H:i:s'.
     1807 *     @type string|bool $show_admin_bar_front Whether to display the Admin Bar for the user on the
     1808 *                                             site's frontend. Default true.
     1809 *     @type string      $role                 User's role.
    18051810 * }
    18061811 * @return int|WP_Error The newly created user's ID or a WP_Error object if the user could not
    18071812 *                      be created.
     
    19691974
    19701975        $meta['rich_editing'] = empty( $userdata['rich_editing'] ) ? 'true' : $userdata['rich_editing'];
    19711976
    1972         $meta['comment_shortcuts'] = empty( $userdata['comment_shortcuts'] ) ? 'false' : $userdata['comment_shortcuts'];
     1977        $meta['comment_shortcuts'] = empty( $userdata['comment_shortcuts'] ) || 'false' === $userdata['comment_shortcuts'] ? 'false' : 'true';
    19731978
    19741979        $admin_color = empty( $userdata['admin_color'] ) ? 'fresh' : $userdata['admin_color'];
    19751980        $meta['admin_color'] = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $admin_color );
  • tests/phpunit/tests/user.php

     
    308308                // Test update of fields in _get_additional_user_keys()
    309309                $user_data = array( 'ID' => $user_id, 'use_ssl' => 1, 'show_admin_bar_front' => 1,
    310310                                                   'rich_editing' => 1, 'first_name' => 'first', 'last_name' => 'last',
    311                                                    'nickname' => 'nick', 'comment_shortcuts' => 1, 'admin_color' => 'classic',
     311                                                   'nickname' => 'nick', 'comment_shortcuts' => 'true', 'admin_color' => 'classic',
    312312                                                   'description' => 'describe' );
    313313                wp_update_user( $user_data );
    314314