Skip to content

Commit

Permalink
Fix possible infinite loop on updating active payment methods (fixes #54
Browse files Browse the repository at this point in the history
).
  • Loading branch information
rvdsteege committed Jan 31, 2022
1 parent 8056dea commit 52e0488
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Core/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,10 @@ public function get_available_payment_methods() {
* Get the payment methods transient
*
* @since 1.3.0
* @param bool $update_active_methods Whether active payment methods option should be updated.
* @return array|null
*/
public function get_transient_available_payment_methods() {
public function get_transient_available_payment_methods( $update_active_methods = true ) {
// Transient name.
$transient = 'pronamic_gateway_payment_methods_' . md5( serialize( $this->config ) );

Expand All @@ -316,7 +317,9 @@ public function get_transient_available_payment_methods() {
if ( is_array( $methods ) ) {
set_transient( $transient, $methods, DAY_IN_SECONDS );

PaymentMethods::update_active_payment_methods();
if ( $update_active_methods ) {
PaymentMethods::update_active_payment_methods();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Core/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ public static function update_active_payment_methods() {
}

try {
$payment_methods = $gateway->get_transient_available_payment_methods();
$payment_methods = $gateway->get_transient_available_payment_methods( false );
} catch ( \Exception $e ) {
// Do not update active payment methods on error.
return;
Expand Down

0 comments on commit 52e0488

Please sign in to comment.