-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
This
patreon-wordpress/classes/patreon_wordpress.php
Lines 564 to 568 in d7f28ff
| public static function getUserPatronage( $user = false ) { | |
| if ( self::$current_user_pledge_amount != -1 ) { | |
| return self::$current_user_pledge_amount; | |
| } |
does not make sense. You accept a user argument but only use one static cache variable. Any call to this function will first check that cache which gets filled by the first valid user. You then return this cached value, regardless of the actual user argument.
This is my proposed solution if you want to keep using the simple cache:
public static function getUserPatronage( $user = false ) {
- if ( self::$current_user_pledge_amount != -1 ) {
- return self::$current_user_pledge_amount;
- }
-
// If user is not given, try to get the current user attribute ID will be 0 if there is no logged in user
if ( $user == false ) {
+ if ( self::$current_user_pledge_amount != -1 ) {
+ return self::$current_user_pledge_amount;
+ }
$user = wp_get_current_user();
}It only uses the cache if you actually request the current user. Ofcourse this isnt perfect, and also not the only place that this would have to be fixed, but i hope you get the general idea.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels