]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
implemented the clear method of the file cache
authorcash <cash.costello@gmail.com>
Thu, 26 Jan 2012 00:30:38 +0000 (19:30 -0500)
committercash <cash.costello@gmail.com>
Thu, 26 Jan 2012 00:30:38 +0000 (19:30 -0500)
engine/classes/ElggFileCache.php

index 8304372dca3e31567aa79418d904085a099cd177..34178d4524c3d34784f11c21e2a78e1de5ae319f 100644 (file)
@@ -161,12 +161,25 @@ class ElggFileCache extends ElggCache {
        }
 
        /**
-        * This was probably meant to delete everything?
+        * Delete all files in the directory of this file cache
         *
         * @return void
         */
        public function clear() {
-               // @todo writeme
+               $dir = $this->getVariable("cache_path");
+
+               $exclude = array(".", "..");
+
+               $files = scandir($dir);
+               if (!$files) {
+                       return;
+               }
+
+               foreach ($files as $f) {
+                       if (!in_array($f, $exclude)) {
+                               unlink($dir . $f);
+                       }
+               }
        }
 
        /**
@@ -184,7 +197,7 @@ class ElggFileCache extends ElggCache {
                        return;
                }
 
-               $exclude = array(".","..");
+               $exclude = array(".", "..");
 
                $files = scandir($dir);
                if (!$files) {