Use string instead of boolean when caching to avoid issues in some environments

This commit is contained in:
Emili Castells Guasch 2023-04-17 12:09:44 +02:00
parent 59ff2d3ca8
commit 97561d3f34
2 changed files with 6 additions and 6 deletions

View file

@ -99,7 +99,7 @@ class DCCProductStatus {
}
if ( $this->cache->has( self::DCC_STATUS_CACHE_KEY ) ) {
return (bool) $this->cache->get( self::DCC_STATUS_CACHE_KEY );
return $this->cache->get( self::DCC_STATUS_CACHE_KEY ) === 'true';
}
if ( $this->current_status_cache === true ) {
@ -135,7 +135,7 @@ class DCCProductStatus {
$this->settings->set( 'products_dcc_enabled', true );
$this->settings->persist();
$this->current_status_cache = true;
$this->cache->set( self::DCC_STATUS_CACHE_KEY, true, 3 * MONTH_IN_SECONDS );
$this->cache->set( self::DCC_STATUS_CACHE_KEY, 'true', 3 * MONTH_IN_SECONDS );
return true;
}
}
@ -144,7 +144,7 @@ class DCCProductStatus {
if ( $this->dcc_applies->for_country_currency() ) {
$expiration = 3 * HOUR_IN_SECONDS;
}
$this->cache->set( self::DCC_STATUS_CACHE_KEY, false, $expiration );
$this->cache->set( self::DCC_STATUS_CACHE_KEY, 'false', $expiration );
$this->current_status_cache = false;
return false;

View file

@ -88,7 +88,7 @@ class PayUponInvoiceProductStatus {
}
if ( $this->cache->has( self::PUI_STATUS_CACHE_KEY ) ) {
return (bool) $this->cache->get( self::PUI_STATUS_CACHE_KEY );
return $this->cache->get( self::PUI_STATUS_CACHE_KEY ) === 'true';
}
if ( $this->current_status_cache === true ) {
@ -127,11 +127,11 @@ class PayUponInvoiceProductStatus {
$this->settings->set( 'products_pui_enabled', true );
$this->settings->persist();
$this->current_status_cache = true;
$this->cache->set( self::PUI_STATUS_CACHE_KEY, true, 3 * MONTH_IN_SECONDS );
$this->cache->set( self::PUI_STATUS_CACHE_KEY, 'true', 3 * MONTH_IN_SECONDS );
return true;
}
}
$this->cache->set( self::PUI_STATUS_CACHE_KEY, false, 3 * MONTH_IN_SECONDS );
$this->cache->set( self::PUI_STATUS_CACHE_KEY, 'false', 3 * MONTH_IN_SECONDS );
$this->current_status_cache = false;
return false;