Skip to content
Snippets Groups Projects

On activation and deactivation, clean up tokens in previous storage

Merged Erick Hitter requested to merge add/activation-hooks into master
1 file
+ 9
2
Compare changes
  • Side-by-side
  • Inline
@@ -65,15 +65,22 @@ final class Activation_Deactivation_Hooks {
@@ -65,15 +65,22 @@ final class Activation_Deactivation_Hooks {
$key = 'session_tokens';
$key = 'session_tokens';
$count = $wpdb->get_var(
$count = $wpdb->get_var(
"SELECT COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '$key'"
$wpdb->prepare(
 
"SELECT COUNT(*) FROM $wpdb->usermeta WHERE meta_key = %s",
 
$key
 
)
);
);
if ( ! $count ) {
if ( ! $count ) {
wp_clear_scheduled_hook( $this->cron_hook );
wp_clear_scheduled_hook( $this->cron_hook );
 
return;
}
}
$wpdb->query(
$wpdb->query(
"DELETE FROM $wpdb->usermeta WHERE meta_key = '$key' LIMIT 500"
$wpdb->prepare(
 
"DELETE FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 500",
 
$key
 
)
);
);
}
}
Loading