mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 14:57:26 +08:00
Cleanup caching data on plugin upgrade
This commit is contained in:
parent
99c5351689
commit
f857315055
3 changed files with 23 additions and 4 deletions
|
@ -102,11 +102,11 @@ class DCCProductStatus {
|
|||
return (bool) $this->cache->get( self::DCC_STATUS_CACHE_KEY );
|
||||
}
|
||||
|
||||
if ( is_bool( $this->current_status_cache ) ) {
|
||||
if ( $this->current_status_cache === true ) {
|
||||
return $this->current_status_cache;
|
||||
}
|
||||
|
||||
if ( $this->settings->has( 'products_dcc_enabled' ) && $this->settings->get( 'products_dcc_enabled' ) ) {
|
||||
if ( $this->settings->has( 'products_dcc_enabled' ) && $this->settings->get( 'products_dcc_enabled' ) === true ) {
|
||||
$this->current_status_cache = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -91,10 +91,10 @@ class PayUponInvoiceProductStatus {
|
|||
return (bool) $this->cache->get( self::PUI_STATUS_CACHE_KEY );
|
||||
}
|
||||
|
||||
if ( is_bool( $this->current_status_cache ) ) {
|
||||
if ( $this->current_status_cache === true ) {
|
||||
return $this->current_status_cache;
|
||||
}
|
||||
if ( $this->settings->has( 'products_pui_enabled' ) && $this->settings->get( 'products_pui_enabled' ) ) {
|
||||
if ( $this->settings->has( 'products_pui_enabled' ) && $this->settings->get( 'products_pui_enabled' ) === true ) {
|
||||
$this->current_status_cache = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace WooCommerce\PayPalCommerce\WcGateway;
|
|||
use Psr\Log\LoggerInterface;
|
||||
use Throwable;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
|
||||
use WC_Order;
|
||||
|
@ -261,6 +262,24 @@ class WCGatewayModule implements ModuleInterface {
|
|||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'woocommerce_paypal_payments_gateway_migrate_on_update',
|
||||
static function() use ( $c ) {
|
||||
$dcc_status_cache = $c->get( 'dcc.status-cache' );
|
||||
assert( $dcc_status_cache instanceof Cache );
|
||||
$pui_status_cache = $c->get( 'pui.status-cache' );
|
||||
assert( $pui_status_cache instanceof Cache );
|
||||
|
||||
$dcc_status_cache->delete( DCCProductStatus::DCC_STATUS_CACHE_KEY );
|
||||
$pui_status_cache->delete( PayUponInvoiceProductStatus::PUI_STATUS_CACHE_KEY );
|
||||
|
||||
$settings = $c->get( 'wcgateway.settings' );
|
||||
$settings->set( 'products_dcc_enabled', false );
|
||||
$settings->set( 'products_pui_enabled', false );
|
||||
$settings->persist();
|
||||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'wp_loaded',
|
||||
function () use ( $c ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue