mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Add initalized flag to prevent migration run multiple times
This commit is contained in:
parent
583dea8d99
commit
d9aa2ab5cd
4 changed files with 9 additions and 10 deletions
File diff suppressed because one or more lines are too long
|
@ -0,0 +1 @@
|
|||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
File diff suppressed because one or more lines are too long
|
@ -178,16 +178,6 @@ class VaultingModule implements ModuleInterface {
|
|||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'pcp_migrate_payment_tokens',
|
||||
function() use ( $container ) {
|
||||
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
||||
assert( $logger instanceof LoggerInterface );
|
||||
|
||||
$this->migrate_payment_tokens( $logger );
|
||||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_payment_tokens_migration',
|
||||
function( int $customer_id ) use ( $container ) {
|
||||
|
@ -218,6 +208,10 @@ class VaultingModule implements ModuleInterface {
|
|||
* @return void
|
||||
*/
|
||||
public function migrate_payment_tokens( LoggerInterface $logger ): void {
|
||||
$initialized = get_option( 'ppcp_payment_tokens_migration_initialized', null );
|
||||
if ( $initialized ) {
|
||||
return;
|
||||
}
|
||||
// phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_key
|
||||
// phpcs:disable WordPress.DB.SlowDBQuery.slow_db_query_meta_query
|
||||
$customers = new WP_User_Query(
|
||||
|
@ -236,6 +230,7 @@ class VaultingModule implements ModuleInterface {
|
|||
}
|
||||
|
||||
$logger->info( 'Starting payment tokens migration for ' . (string) count( $customers ) . ' users' );
|
||||
update_option( 'ppcp_payment_tokens_migration_initialized', true );
|
||||
|
||||
$interval_in_seconds = 5;
|
||||
$timestamp = time();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue