X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FCache.php;h=e5d43e611656823eaef4b952219f9a7755198026;hb=d8acf8550480694d050091e270a06c01e7b313f0;hp=9c7e818fe7a99c05b60e3419de4f9d048e0a1b08;hpb=01e48f269df59e02798dad4a698c125d76b0ed70;p=github%2Fshaarli%2FShaarli.git diff --git a/application/Cache.php b/application/Cache.php index 9c7e818f..e5d43e61 100644 --- a/application/Cache.php +++ b/application/Cache.php @@ -7,26 +7,18 @@ * Purges all cached pages * * @param string $pageCacheDir page cache directory + * + * @return mixed an error string if the directory is missing */ function purgeCachedPages($pageCacheDir) { if (! is_dir($pageCacheDir)) { - return; + $error = sprintf(t('Cannot purge %s: no directory'), $pageCacheDir); + error_log($error); + return $error; } - // TODO: check write access to the cache directory - - $handler = opendir($pageCacheDir); - if ($handler == false) { - return; - } - - while (($filename = readdir($handler)) !== false) { - if (endsWith($filename, '.cache')) { - unlink($pageCacheDir.'/'.$filename); - } - } - closedir($handler); + array_map('unlink', glob($pageCacheDir.'/*.cache')); } /**