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 { |
580 | 580 | * Execute the query, with the current variables. |
581 | 581 | * |
582 | 582 | * @since 3.1.0 |
583 | | * |
584 | | * @global wpdb $wpdb WordPress database abstraction object. |
585 | 583 | */ |
586 | 584 | 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() { |
587 | 601 | global $wpdb; |
588 | 602 | |
589 | 603 | $qv =& $this->query_vars; |
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 { |
121 | 121 | * @param int $site_id Optional Site ID, defaults to current site. |
122 | 122 | */ |
123 | 123 | 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(); |
135 | 125 | |
136 | 126 | if ( $id instanceof WP_User ) { |
137 | 127 | $this->init( $id->data, $site_id ); |
… |
… |
class WP_User { |
822 | 812 | return $this->site_id; |
823 | 813 | } |
824 | 814 | |
| 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 | |
825 | 831 | /** |
826 | 832 | * Gets the available user capabilities data. |
827 | 833 | * |
… |
… |
class WP_User { |
829 | 835 | * |
830 | 836 | * @return array User capabilities array. |
831 | 837 | */ |
832 | | private function get_caps_data() { |
| 838 | protected function get_caps_data() { |
833 | 839 | $caps = get_user_meta( $this->ID, $this->cap_key, true ); |
834 | 840 | |
835 | 841 | if ( ! is_array( $caps ) ) { |
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 ) { |
1691 | 1691 | */ |
1692 | 1692 | $data = apply_filters( 'wp_pre_insert_user_data', $data, $update, $update ? (int) $ID : null ); |
1693 | 1693 | |
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; |
1700 | 1697 | } 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 | } |
1704 | 1708 | |
1705 | | $user = new WP_User( $user_id ); |
| 1709 | $user = new WP_User( $user_id ); |
| 1710 | } |
1706 | 1711 | |
1707 | 1712 | /** |
1708 | 1713 | * Filters a user's meta values and keys immediately after the user is created or updated |
… |
… |
function wp_get_password_hint() { |
2122 | 2127 | * |
2123 | 2128 | * @since 4.4.0 |
2124 | 2129 | * |
2125 | | * @global wpdb $wpdb WordPress database abstraction object. |
2126 | 2130 | * @global PasswordHash $wp_hasher Portable PHP password hashing framework. |
2127 | 2131 | * |
2128 | 2132 | * @param WP_User $user User to retrieve password reset key for. |
… |
… |
function get_password_reset_key( $user ) { |
2219 | 2223 | * @return WP_User|WP_Error WP_User object on success, WP_Error object for invalid or expired keys. |
2220 | 2224 | */ |
2221 | 2225 | function check_password_reset_key($key, $login) { |
2222 | | global $wpdb, $wp_hasher; |
| 2226 | global $wp_hasher; |
2223 | 2227 | |
2224 | 2228 | $key = preg_replace('/[^a-z0-9]/i', '', $key); |
2225 | 2229 | |
… |
… |
function check_password_reset_key($key, $login) { |
2229 | 2233 | if ( empty($login) || !is_string($login) ) |
2230 | 2234 | return new WP_Error('invalid_key', __('Invalid key')); |
2231 | 2235 | |
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 ) |
2234 | 2238 | return new WP_Error('invalid_key', __('Invalid key')); |
2235 | 2239 | |
2236 | 2240 | if ( empty( $wp_hasher ) ) { |