Make WordPress Core

Changeset 3465


Ignore:
Timestamp:
01/19/2006 10:12:15 PM (18 years ago)
Author:
ryan
Message:

Cache flush improvements from Owen. fixes #2223 #2278

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/cache.php

    r3462 r3465  
    236236        $top_dir = $dir;
    237237        $stack = array($dir);
    238 
    239         while (count($stack)) {
    240             # Get last directory on stack
    241             $dir = end($stack);
     238        $index = 0;
     239
     240        while ($index < count($stack)) {
     241            # Get indexed directory from stack
     242            $dir = $stack[$index];
    242243     
    243244            $dh = @ opendir($dir);
     
    248249                if ($file == '.' or $file == '..')
    249250                    continue;
    250 
     251                   
    251252                if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
    252253                    $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
     
    255256            }
    256257
    257             if (end($stack) == $dir) {
    258                 if ( $dir != $top_dir)
    259                     @ rmdir($dir);
    260                 array_pop($stack);
    261             }
    262         }
     258            $index++;
     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
    263267    }
    264268
     
    404408            $this->cache_dir = CACHE_PATH;
    405409        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;
    407412
    408413        if (is_writable($this->cache_dir) && is_dir($this->cache_dir)) {
Note: See TracChangeset for help on using the changeset viewer.