aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Cache.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/Cache.php')
-rw-r--r--application/Cache.php20
1 files changed, 6 insertions, 14 deletions
diff --git a/application/Cache.php b/application/Cache.php
index 9c7e818f..5d050165 100644
--- a/application/Cache.php
+++ b/application/Cache.php
@@ -7,26 +7,18 @@
7 * Purges all cached pages 7 * Purges all cached pages
8 * 8 *
9 * @param string $pageCacheDir page cache directory 9 * @param string $pageCacheDir page cache directory
10 *
11 * @return mixed an error string if the directory is missing
10 */ 12 */
11function purgeCachedPages($pageCacheDir) 13function purgeCachedPages($pageCacheDir)
12{ 14{
13 if (! is_dir($pageCacheDir)) { 15 if (! is_dir($pageCacheDir)) {
14 return; 16 $error = 'Cannot purge '.$pageCacheDir.': no directory';
17 error_log($error);
18 return $error;
15 } 19 }
16 20
17 // TODO: check write access to the cache directory 21 array_map('unlink', glob($pageCacheDir.'/*.cache'));
18
19 $handler = opendir($pageCacheDir);
20 if ($handler == false) {
21 return;
22 }
23
24 while (($filename = readdir($handler)) !== false) {
25 if (endsWith($filename, '.cache')) {
26 unlink($pageCacheDir.'/'.$filename);
27 }
28 }
29 closedir($handler);
30} 22}
31 23
32/** 24/**