Changeset 348

Show
Ignore:
Timestamp:
03/07/07 16:17:42 (1 year ago)
Author:
mikey
Message:

added internal check if cached file needs refreshing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/docroot/xml.php

    r342 r348  
    2323    public static function main() 
    2424    { 
    25         $directory = new DirectoryIterator(stubConfig::getCachePath() . '/xml'); 
    26         foreach ($directory as $file) { 
    27             if ($file->isDot() == true || $file->getFilename() == '.svn') { 
    28                 continue; 
    29             } 
    30              
    31             unlink($file->getPathname()); 
    32         } 
    33          
    3425        $request        = new stubWebRequest(); 
    3526        $session        = new stubPHPSession('stubSID'); 
  • trunk/src/main/php/net/stubbles/xml/stubXMLXIncludeStreamWrapper.php

    r347 r348  
    134134        } 
    135135         
    136         if (file_exists($this->cachedFileName) == false) { 
     136        if (file_exists($this->cachedFileName) == false || $this->needsRefresh() == true) { 
    137137            $this->processFile(); 
    138138        } 
     
    144144         
    145145        $this->fp = $fp; 
     146        return true; 
     147    } 
     148     
     149    /** 
     150     * check whether the cached file needs to be refreshed 
     151     * 
     152     * @return  bool 
     153     */ 
     154    protected function needsRefresh() 
     155    { 
     156        if (filemtime($this->cachedFileName) > filemtime($this->fileName))  { 
     157            return false; 
     158        } 
     159         
    146160        return true; 
    147161    }