Make WordPress Core

Ticket #43635: patch

File patch, 5.1 KB (added by freeaqingme, 7 years ago)
  • public/wp-includes/class-wp-user-query.php

    git diff HEAD~8 HEAD  ':!public/wp-content/plugins' ':!public/wp-config.php'  public/ > patch
    diff --git a/public/wp-includes/class-wp-user-query.php b/public/wp-includes/class-wp-user-query.php
    index b2462dcf1d..b695d48273 100644
    a b class WP_User_Query { 
    580580         * Execute the query, with the current variables.
    581581         *
    582582         * @since 3.1.0
    583          *
    584          * @global wpdb $wpdb WordPress database abstraction object.
    585583         */
    586584        public function query() {
     585        if (!has_action('user_query')) {
     586            $this->_query();
     587            return;
     588        }
     589
     590        do_action( 'user_query', $this );
     591    }
     592
     593    /**
     594     * Execute the query, varswith the current variables.
     595     *
     596     * @since 3.1.0
     597     *
     598     * @global wpdb $wpdb WordPress database abstraction object.
     599     */
     600    protected function _query() {
    587601                global $wpdb;
    588602
    589603                $qv =& $this->query_vars;
  • public/wp-includes/class-wp-user.php

    diff --git a/public/wp-includes/class-wp-user.php b/public/wp-includes/class-wp-user.php
    index 4a90439ba3..f20598a662 100644
    a b class WP_User { 
    121121         * @param int $site_id Optional Site ID, defaults to current site.
    122122         */
    123123        public function __construct( $id = 0, $name = '', $site_id = '' ) {
    124                 if ( ! isset( self::$back_compat_keys ) ) {
    125                         $prefix = $GLOBALS['wpdb']->prefix;
    126                         self::$back_compat_keys = array(
    127                                 'user_firstname' => 'first_name',
    128                                 'user_lastname' => 'last_name',
    129                                 'user_description' => 'description',
    130                                 'user_level' => $prefix . 'user_level',
    131                                 $prefix . 'usersettings' => $prefix . 'user-settings',
    132                                 $prefix . 'usersettingstime' => $prefix . 'user-settings-time',
    133                         );
    134                 }
     124                $this->initialize_back_compat_keys();
    135125
    136126                if ( $id instanceof WP_User ) {
    137127                        $this->init( $id->data, $site_id );
    class WP_User { 
    822812                return $this->site_id;
    823813        }
    824814
     815        protected function initialize_back_compat_keys() {
     816                if ( isset( self::$back_compat_keys ) ) {
     817                        return;
     818                }
     819
     820                $prefix                 = $GLOBALS['wpdb']->prefix;
     821                self::$back_compat_keys = array(
     822                        'user_firstname'             => 'first_name',
     823                        'user_lastname'              => 'last_name',
     824                        'user_description'           => 'description',
     825                        'user_level'                 => $prefix . 'user_level',
     826                        $prefix . 'usersettings'     => $prefix . 'user-settings',
     827                        $prefix . 'usersettingstime' => $prefix . 'user-settings-time',
     828                );
     829        }
     830
    825831        /**
    826832         * Gets the available user capabilities data.
    827833         *
    class WP_User { 
    829835         *
    830836         * @return array User capabilities array.
    831837         */
    832         private function get_caps_data() {
     838        protected function get_caps_data() {
    833839                $caps = get_user_meta( $this->ID, $this->cap_key, true );
    834840
    835841                if ( ! is_array( $caps ) ) {
  • public/wp-includes/user.php

    diff --git a/public/wp-includes/user.php b/public/wp-includes/user.php
    index 1c1e466bf4..9c01ee37f3 100644
    a b function wp_insert_user( $userdata ) { 
    16911691         */
    16921692        $data = apply_filters( 'wp_pre_insert_user_data', $data, $update, $update ? (int) $ID : null );
    16931693
    1694         if ( $update ) {
    1695                 if ( $user_email !== $old_user_data->user_email ) {
    1696                         $data['user_activation_key'] = '';
    1697                 }
    1698                 $wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
    1699                 $user_id = (int) $ID;
     1694        if ( $data instanceof WP_User ) {
     1695                $user = $data;
     1696                $user_id = $user->ID;
    17001697        } else {
    1701                 $wpdb->insert( $wpdb->users, $data );
    1702                 $user_id = (int) $wpdb->insert_id;
    1703         }
     1698                if ( $update ) {
     1699                        if ( $user_email !== $old_user_data->user_email ) {
     1700                                $data['user_activation_key'] = '';
     1701                        }
     1702                        $wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
     1703                        $user_id = (int) $ID;
     1704                } else {
     1705                        $wpdb->insert( $wpdb->users, $data );
     1706                        $user_id = (int) $wpdb->insert_id;
     1707                }
    17041708
    1705         $user = new WP_User( $user_id );
     1709                $user = new WP_User( $user_id );
     1710        }
    17061711
    17071712        /**
    17081713         * Filters a user's meta values and keys immediately after the user is created or updated
    function wp_get_password_hint() { 
    21222127 *
    21232128 * @since 4.4.0
    21242129 *
    2125  * @global wpdb         $wpdb      WordPress database abstraction object.
    21262130 * @global PasswordHash $wp_hasher Portable PHP password hashing framework.
    21272131 *
    21282132 * @param WP_User $user User to retrieve password reset key for.
    function get_password_reset_key( $user ) { 
    22192223 * @return WP_User|WP_Error WP_User object on success, WP_Error object for invalid or expired keys.
    22202224 */
    22212225function check_password_reset_key($key, $login) {
    2222         global $wpdb, $wp_hasher;
     2226        global $wp_hasher;
    22232227
    22242228        $key = preg_replace('/[^a-z0-9]/i', '', $key);
    22252229
    function check_password_reset_key($key, $login) { 
    22292233        if ( empty($login) || !is_string($login) )
    22302234                return new WP_Error('invalid_key', __('Invalid key'));
    22312235
    2232         $row = $wpdb->get_row( $wpdb->prepare( "SELECT ID, user_activation_key FROM $wpdb->users WHERE user_login = %s", $login ) );
    2233         if ( ! $row )
     2236        $row = get_user_by('login', $login);
     2237        if ( ! $row instanceof WP_User )
    22342238                return new WP_Error('invalid_key', __('Invalid key'));
    22352239
    22362240        if ( empty( $wp_hasher ) ) {