Cache flush improvements from Owen. fixes #2223 #2278

git-svn-id: http://svn.automattic.com/wordpress/trunk@3465 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-01-19 22:12:15 +00:00
parent 30be2a8f69
commit ee7a432c55
1 changed files with 15 additions and 10 deletions

View File

@ -235,10 +235,11 @@ class WP_Object_Cache {
$dir = rtrim($dir, DIRECTORY_SEPARATOR); $dir = rtrim($dir, DIRECTORY_SEPARATOR);
$top_dir = $dir; $top_dir = $dir;
$stack = array($dir); $stack = array($dir);
$index = 0;
while (count($stack)) { while ($index < count($stack)) {
# Get last directory on stack # Get indexed directory from stack
$dir = end($stack); $dir = $stack[$index];
$dh = @ opendir($dir); $dh = @ opendir($dir);
if (!$dh) if (!$dh)
@ -247,19 +248,22 @@ class WP_Object_Cache {
while (($file = @ readdir($dh)) !== false) { while (($file = @ readdir($dh)) !== false) {
if ($file == '.' or $file == '..') if ($file == '.' or $file == '..')
continue; continue;
if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file)) if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
$stack[] = $dir . DIRECTORY_SEPARATOR . $file; $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file)) else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file))
@ unlink($dir . DIRECTORY_SEPARATOR . $file); @ unlink($dir . DIRECTORY_SEPARATOR . $file);
} }
if (end($stack) == $dir) { $index++;
if ( $dir != $top_dir)
@ rmdir($dir);
array_pop($stack);
}
} }
$stack = array_reverse($stack); // Last added dirs are deepest
foreach($stack as $dir) {
if ( $dir != $top_dir)
@ rmdir($dir);
}
} }
function release_lock() { function release_lock() {
@ -403,7 +407,8 @@ class WP_Object_Cache {
if (defined('CACHE_PATH')) if (defined('CACHE_PATH'))
$this->cache_dir = CACHE_PATH; $this->cache_dir = CACHE_PATH;
else else
$this->cache_dir = ABSPATH.'wp-content/cache/'; // Using the correct separator eliminates some cache flush errors on Windows
$this->cache_dir = ABSPATH.'wp-content'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR;
if (is_writable($this->cache_dir) && is_dir($this->cache_dir)) { if (is_writable($this->cache_dir) && is_dir($this->cache_dir)) {
$this->cache_enabled = true; $this->cache_enabled = true;