Ticket #2223: cache.php.diff
File cache.php.diff, 1.6 KB (added by , 19 years ago) |
---|
-
cache.php
235 235 $dir = rtrim($dir, DIRECTORY_SEPARATOR); 236 236 $top_dir = $dir; 237 237 $stack = array($dir); 238 $index = 0; 238 239 239 while ( count($stack)) {240 # Get last directory onstack241 $dir = end($stack);240 while ($index < count($stack)) { 241 # Get indexed directory from stack 242 $dir = $stack[$index]; 242 243 243 244 $dh = @ opendir($dir); 244 245 if (!$dh) … … 247 248 while (($file = @ readdir($dh)) !== false) { 248 249 if ($file == '.' or $file == '..') 249 250 continue; 250 251 251 252 if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file)) 252 253 $stack[] = $dir . DIRECTORY_SEPARATOR . $file; 253 254 else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file)) 254 255 @ unlink($dir . DIRECTORY_SEPARATOR . $file); 255 256 } 256 257 257 if (end($stack) == $dir) { 258 if ( $dir != $top_dir) 259 @ rmdir($dir); 260 array_pop($stack); 261 } 258 $index++; 262 259 } 260 261 $stack = array_reverse($stack); // Last added dirs are deepest 262 foreach($stack as $dir) { 263 if ( $dir != $top_dir) 264 @ rmdir($dir); 265 } 266 263 267 } 264 268 265 269 function release_lock() { … … 403 407 if (defined('CACHE_PATH')) 404 408 $this->cache_dir = CACHE_PATH; 405 409 else 406 $this->cache_dir = ABSPATH.'wp-content/cache/'; 410 // Using the correct separator eliminates some cache flush errors on Windows 411 $this->cache_dir = ABSPATH.'wp-content'.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR; 407 412 408 413 if (is_writable($this->cache_dir) && is_dir($this->cache_dir)) { 409 414 $this->cache_enabled = true;