♻️ Refactor 3DS migration to run only when needed

This commit is contained in:
Daniel Dudzic 2025-06-10 14:58:47 +02:00
parent 3443cd0ecf
commit df8709aee9
No known key found for this signature in database
GPG key ID: 31B40D33E3465483

View file

@ -282,20 +282,17 @@ class CompatModule implements ServiceModule, ExtendingModule, ExecutableModule {
* The migration will be done on plugin update if it hasn't already done.
*/
protected function migrate_three_d_secure_setting(): void {
$payment_settings = get_option( 'woocommerce-ppcp-data-payment' ) ?: array();
$data_settings = get_option( 'woocommerce-ppcp-data-settings' ) ?: array();
// Skip if payment settings don't have the setting but data settings do.
if ( ! isset( $payment_settings['three_d_secure'] ) && isset( $data_settings['three_d_secure'] ) ) {
return;
}
add_action(
'woocommerce_paypal_payments_gateway_migrate_on_update',
function () {
$payment_settings = get_option( 'woocommerce-ppcp-data-payment' ) ?: array();
$data_settings = get_option( 'woocommerce-ppcp-data-settings' ) ?: array();
// Skip if payment settings don't have the setting but data settings do.
if ( ! isset( $payment_settings['three_d_secure'] ) && isset( $data_settings['three_d_secure'] ) ) {
return;
}
// Move the setting.
$data_settings['three_d_secure'] = $payment_settings['three_d_secure'];
unset( $payment_settings['three_d_secure'] );