Skip to content

Commit

Permalink
throw ex during migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Timur Karimov committed Mar 28, 2024
1 parent 7c0fde3 commit a56d29d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions includes/migrations/class-gateway-settings-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace WCPay\Migrations;

use Exception;
use WC_Payment_Gateway_WCPay;

defined( 'ABSPATH' ) || exit;
Expand Down Expand Up @@ -63,20 +64,14 @@ public function maybe_sync() {

/**
* Syncs gateway setting objects.
*
* @throws Exception
*/
private function sync() {
$enabled_payment_methods = $this->main_gateway->get_option( 'upe_enabled_payment_method_ids', [] );

foreach ( $this->all_registered_gateways as $gateway ) {
// Skip the main gateway as it's settings are already in sync.
if ( 'card' !== $gateway->get_stripe_id() ) {
if ( in_array( $gateway->get_stripe_id(), $enabled_payment_methods, true ) ) {
$gateway->enable();
$gateway->update_option( 'upe_enabled_payment_method_ids', $enabled_payment_methods );
} else {
$gateway->update_option( 'upe_enabled_payment_method_ids', $enabled_payment_methods );
}
}
throw new Exception( 'Migration unsuccessful.' );
}
}
}

0 comments on commit a56d29d

Please sign in to comment.