Changeset 10086 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/clients/class-github.php
- Timestamp:
- 07/21/2020 04:02:38 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/clients/class-github.php
r10076 r10086 43 43 */ 44 44 protected static function get_app_install_token() { 45 $token = false;get_site_transient( __CLASS__ . 'app_install_token' );46 if ( $token ) {47 return $token ;45 $token = get_site_transient( __CLASS__ . 'app_install_token' ); 46 if ( $token && is_array( $token ) && $token['exp'] > time() ) { 47 return $token['token']; 48 48 } 49 49 … … 88 88 89 89 // Cache the token for 1 minute less than what it's valid for. 90 set_site_transient( __CLASS__ . 'app_install_token', $token, $token_exp - time() - MINUTE_IN_SECONDS ); 90 $exp = $token_exp - time() - MINUTE_IN_SECONDS; 91 set_site_transient( __CLASS__ . 'app_install_token', [ 'exp' => time() + $exp, 'token' => $token ], $exp ); 91 92 92 93 return $token; … … 98 99 protected static function get_jwt_app_token() { 99 100 $token = get_site_transient( __CLASS__ . 'app_token' ); 100 if ( $token ) {101 return $token ;101 if ( $token && is_array( $token ) && $token['exp'] > time() ) { 102 return $token['token']; 102 103 } 103 104 … … 119 120 120 121 // Cache it for 9 mins (It's valid for 10min). 121 set_site_transient( __CLASS__ . 'app_token', $token, 9 * MINUTE_IN_SECONDS ); 122 $exp = 9 * MINUTE_IN_SECONDS; 123 set_site_transient( __CLASS__ . 'app_token', [ 'exp' => time() + $exp, 'token' => $token ], $exp ); 122 124 123 125 return $token;
Note: See TracChangeset
for help on using the changeset viewer.