Skip to content

Commit

Permalink
Rewrote
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed Feb 13, 2024
1 parent 548f7d8 commit 265f071
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions app/code/core/Mage/Core/Model/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,10 @@ public function saveOptions($options)
$this->remove(self::OPTIONS_CACHE_ID);
$this->_getResource()->saveAllOptions($options);
foreach ($options as $typeCode => $enabled) {
$this->saveUpdatedAt($typeCode, (bool)$enabled);
if ($enabled && !$this->_allowedCacheOptions[$typeCode]) {
// save the updated_at only if we're enabling a previously disabled cache
$this->saveUpdatedAt($typeCode);
}
}
return $this;
}
Expand Down Expand Up @@ -590,7 +593,7 @@ public function getTypes()
'description' => Mage::helper('core')->__((string)$node->description),
'tags' => strtoupper((string)$node->tags),
'status' => (int)$this->canUse($type),
'updated_at' => (string)$this->load($node->tags . '_updated_at'),
'updated_at' => $this->_allowedCacheOptions[$type] ? (string)$this->load($node->tags . '_updated_at') : '',
]);
}
}
Expand Down Expand Up @@ -684,34 +687,22 @@ public function cleanType($typeCode)

/**
* @param string $typeCode
* @param bool|null $isCacheEnabled
* @return void
*/
public function saveUpdatedAt($typeCode, $isCacheEnabled = null): void
public function saveUpdatedAt($typeCode): void
{
if (!array_key_exists($typeCode, $this->_allowedCacheOptions)) {
return;
}

if ($isCacheEnabled === null) {
$isCacheEnabled = $this->_allowedCacheOptions[$typeCode];
} elseif ($isCacheEnabled == $this->_allowedCacheOptions[$typeCode]) {
// if this cache was already enabled or already disabled, don't save updatedAt
return;
}

$path = self::XML_PATH_TYPES . '/' . $typeCode . '/tags';
$tagsConfig = Mage::getConfig()->getNode($path);
if (!$tagsConfig) {
return;
}

$cacheId = (string)$tagsConfig . '_updated_at';
if ($isCacheEnabled) {
$this->save(Mage::getSingleton('core/date')->gmtDate(), $cacheId);
} else {
$this->remove($cacheId);
}
$this->save(Mage::getSingleton('core/date')->gmtDate(), $cacheId);
}

/**
Expand Down

0 comments on commit 265f071

Please sign in to comment.