From 0940c8c86318dd5de323b9d00d3b2d0e6f82d0f0 Mon Sep 17 00:00:00 2001 From: Simon Costea Date: Thu, 7 May 2020 10:51:44 +0300 Subject: [PATCH] Delete expired transients --- includes/openid-connect-generic-client.php | 3 +-- openid-connect-generic.php | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/openid-connect-generic-client.php b/includes/openid-connect-generic-client.php index eb59904..e3e58f8 100644 --- a/includes/openid-connect-generic-client.php +++ b/includes/openid-connect-generic-client.php @@ -248,8 +248,7 @@ class OpenID_Connect_Generic_Client { function new_state() { // new state w/ timestamp $state = md5( mt_rand() . microtime( true ) ); - $expire = time() + $this->state_time_limit; - set_transient( 'openid-connect-generic-state--' . $state, $state, $expire ); + set_transient( 'openid-connect-generic-state--' . $state, $state, $this->state_time_limit ); return $state; } diff --git a/openid-connect-generic.php b/openid-connect-generic.php index 0b62366..f9e479a 100644 --- a/openid-connect-generic.php +++ b/openid-connect-generic.php @@ -183,11 +183,12 @@ class OpenID_Connect_Generic { */ function cron_states_garbage_collection() { global $wpdb; - $states = $wpdb->get_col( "SELECT `option_name` FROM {$wpdb->options} WHERE `option_name` LIKE 'openid-connect-generic-state--%'" ); + $states = $wpdb->get_col( "SELECT `option_name` FROM {$wpdb->options} WHERE `option_name` LIKE '_transient_openid-connect-generic-state--%'" ); if ( !empty( $states ) ) { foreach ( $states as $state ) { - get_transient( $state ); + $transient = str_replace("_transient_", "", $state); + get_transient( $transient ); } } }