0

When I try to clear the cache from Manager or from a snippet on MODX3.0.2, MODX does not empty the folders under core/cache/resource/ and the cache won't be cleared.

I traced the problem to xPDOFileCache.php:

public function delete($key, $options= array()) {
    $deleted= false;
    if ($this->getOption(xPDO::OPT_CACHE_MULTIPLE_OBJECT_DELETE, $options, false)) { 
        $cacheKey= $this->getCacheKey($key, array_merge($options, array('cache_ext' => '')));
        if (file_exists($cacheKey) && is_dir($cacheKey)) {
            $results = $this->xpdo->cacheManager->deleteTree($cacheKey, array_merge(array('deleteTop' => false, 'skipDirs' => false, 'extensions' => array('.cache.php')), $options));
            if ($results !== false) {
                $deleted = true;
            }
        }
    }
    $cacheKey= $this->getCacheKey($key, $options);
    if (file_exists($cacheKey)) {
        $deleted= @ unlink($cacheKey);
    }
    return $deleted;
}

If condition on line 3 returns false so deleteTree won't be executed and the folder won't be emptied. Could someone tell me, what is that condition about and why it returns false? Is it something related to my installation?

2 Answers2

0

Quick answer: as far as I remember this behavior depends on some system setting, I'll let you know shortly

Anton Tarasov
  • 534
  • 1
  • 7
  • 16
  • I turned cache_resource_clear_partial OFF and the problem disappeared. Was it this you are looking for? – Niko Suominen Jan 05 '23 at 10:25
  • Yes, this is what i'm thinking about, `cache_resource_clear_partial` – Anton Tarasov Jan 06 '23 at 10:25
  • It helped because the cache is then cleared in a different way. But I think there is a bug because partial cache clearing does not work. I don't need partial clearing so my problem was solved. In version 2.8, the partial clearing was still working. – Niko Suominen Jan 07 '23 at 09:02
0

Turning the cache_resource_clear_partial setting off is a workaround.

The original reason for the problem is probably a bug which has been reported on GitHub now.