Skip to content

Commit

Permalink
refactor direct db query to use WP_User_Query
Browse files Browse the repository at this point in the history
  • Loading branch information
aaemnnosttv committed Oct 31, 2019
1 parent 9ac1a86 commit bd3cb37
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions includes/Core/Util/Migration_1_0_0.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,15 @@ private function disconnect_users() {
$user_options = new User_Options( $this->context );
$authentication = new Authentication( $this->context, $this->options, $user_options );

$user_ids = $wpdb->get_col(
$wpdb->prepare(
"
SELECT user_id
FROM {$wpdb->usermeta}
WHERE meta_key IN ( %s, %s )
",
OAuth_Client::OPTION_ACCESS_TOKEN,
$wpdb->get_blog_prefix() . OAuth_Client::OPTION_ACCESS_TOKEN
// User option keys are prefixed in single site and multisite when not in network mode.
$key_prefix = $this->context->is_network_mode() ? '' : $wpdb->get_blog_prefix();
$user_ids = ( new \WP_User_Query(
array(
'fields' => 'id',
'meta_key' => $key_prefix . OAuth_Client::OPTION_ACCESS_TOKEN,
'compare' => 'EXISTS',
)
);
) )->get_results();

foreach ( $user_ids as $user_id ) {
$user_options->switch_user( (int) $user_id );
Expand Down

0 comments on commit bd3cb37

Please sign in to comment.