diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-01-05 09:31:17 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-01-05 09:31:17 +0000 |
| commit | b57ac48281c44847de6f128c109c5d13bd46d1cc (patch) | |
| tree | e30de50e289a9ae890d45ab4f34513ff39532d8b /wp-inst/wp-includes/cache.php | |
| parent | 6236ff5e9118e0d334e0a55713f5f434ca8e332d (diff) | |
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@492 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-includes/cache.php')
| -rw-r--r-- | wp-inst/wp-includes/cache.php | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/wp-inst/wp-includes/cache.php b/wp-inst/wp-includes/cache.php index af932a7..0ae4350 100644 --- a/wp-inst/wp-includes/cache.php +++ b/wp-inst/wp-includes/cache.php @@ -91,7 +91,7 @@ class WP_Object_Cache { if ( !$this->cache_enabled ) return; - $this->rm($this->cache_dir.'*'); + $this->rm_cache_dir(); $this->cache = array (); $this->dirty_objects = array (); $this->non_existant_objects = array (); @@ -214,25 +214,36 @@ class WP_Object_Cache { return $this->cache_dir."$group_dir/"; } - function rm($fileglob) { - if (is_file($fileglob)) { - return @ unlink($fileglob); - } else - if (is_dir($fileglob)) { - $ok = WP_Object_Cache::rm("$fileglob/*"); - if (!$ok) - return false; - return @ rmdir($fileglob); - } else { - $matching = glob($fileglob); - if ($matching === false) - return true; - $rcs = array_map(array ('WP_Object_Cache', 'rm'), $matching); - if (in_array(false, $rcs)) { - return false; - } + function rm_cache_dir() { + $dir = $this->cache_dir; + $dir = rtrim($dir, DIRECTORY_SEPARATOR); + $top_dir = $dir; + $stack = array($dir); + + while (count($stack)) { + # Get last directory on stack + $dir = end($stack); + + $dh = @ opendir($dir); + if (!$dh) + return false; + + while (($file = @ readdir($dh)) !== false) { + if ($file == '.' or $file == '..') + continue; + + if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file)) + $stack[] = $dir . DIRECTORY_SEPARATOR . $file; + else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file)) + @ unlink($dir . DIRECTORY_SEPARATOR . $file); } - return true; + + if (end($stack) == $dir) { + if ( $dir != $top_dir) + @ rmdir($dir); + array_pop($stack); + } + } } function replace($id, $data, $group = 'default', $expire = '') { |
