diff --git a/web/classes/contentcache.class.php b/web/classes/contentcache.class.php index c95584c2dc..8e656999f0 100644 --- a/web/classes/contentcache.class.php +++ b/web/classes/contentcache.class.php @@ -81,12 +81,12 @@ public function store($file, $content) /** * Is the specified content element present in the cache? * - * @param file (String) File name to look up. + * @param relPath (String) File name to look up. * @return (Boolean) TRUE iff the content element is available. */ - public function isPresent($file) + public function isPresent($relPath) { - return (bool) file_exists(FrontController::nativePath($this->_docRoot."/$file")); + return (bool) file_exists(FrontController::nativePath($this->_docRoot."/$relPath")); } /** @@ -116,30 +116,33 @@ public function retrieve($relPath) /** * Retrieve info about a file in the cache. * - * @param file (String) Name of the file to get info for. + * @param relPath (String) Name of the file to get info for. + * @param info (ContentInfo) Info record to be populated. * @return (Boolean) FALSE if the specified file does not exist. */ - public function getInfo($file, &$ContentInfo) + public function getInfo($relPath, &$info) { - $file = FrontController::nativePath($this->_docRoot."/$file"); - if(!$file || !file_exists($file)) return FALSE; + if(!$info instanceof ContentInfo) return FALSE; - $ContentInfo->modifiedTime = filemtime($file); + $path = FrontController::nativePath($this->_docRoot."/$relPath"); + if(!$path || !file_exists($path)) return FALSE; + + $info->modifiedTime = filemtime($path); return TRUE; } /** * Touch a file in the cache (update modified time). * - * @param file (String) Name of the file to touch. + * @param relPath (String) Name of the file to touch. * @return (Boolean) FALSE if the specified file does not exist. */ - public function touch($file) + public function touch($relPath) { - $file = FrontController::nativePath($this->_docRoot."/$file"); - if(!$file || !file_exists($file)) return FALSE; + $path = FrontController::nativePath($this->_docRoot."/$relPath"); + if(!$path || !file_exists($path)) return FALSE; - touch($file); + touch($path); return TRUE; } @@ -147,16 +150,16 @@ public function touch($file) * Attempt to import a content element from the cache, outputting * its contents straight to the output buffer. * - * @param file (String) File name to retrieve. + * @param relPath (String) File name to retrieve. * @return (Boolean) TRUE iff the content element was imported. */ - public function import($file) + public function import($relPath) { - $file = FrontController::nativePath($this->_docRoot."/$file"); + $path = FrontController::nativePath($this->_docRoot."/$relPath"); - if(!$file || !file_exists($file)) - throw new Exception(sprintf('file %s not present in content cache.', $file)); + if(!$path || !file_exists($path)) + throw new Exception(sprintf('file %s not present in content cache.', $relPath)); - return @readfile($file); + return @readfile($path); } } diff --git a/web/plugins/buildrepository/buildrepository.php b/web/plugins/buildrepository/buildrepository.php index 82a4378914..7d067da16c 100644 --- a/web/plugins/buildrepository/buildrepository.php +++ b/web/plugins/buildrepository/buildrepository.php @@ -103,7 +103,7 @@ function mustUpdateCachedBuildLog(&$buildLogUri, &$cacheName) // to determine when it is time to query (we touch the cached copy after // each query attempt). $cacheInfo = new ContentInfo(); - $FrontController->contentCache()->getInfo($cacheName, &$cacheInfo); + $FrontController->contentCache()->getInfo($cacheName, $cacheInfo); if(time() < strtotime('+5 minutes', $cacheInfo->modifiedTime)) return FALSE; @@ -1060,7 +1060,7 @@ private function outputPackageGraph(&$pack) if($FrontController->contentCache()->isPresent($cacheName)) { $cacheInfo = new ContentInfo(); - $FrontController->contentCache()->getInfo($cacheName, &$contentInfo); + $FrontController->contentCache()->getInfo($cacheName, $contentInfo); header('Pragma: public'); header('Cache-Control: public'); diff --git a/web/plugins/masterbrowser/masterbrowser.php b/web/plugins/masterbrowser/masterbrowser.php index 097273be59..fa6ded4967 100644 --- a/web/plugins/masterbrowser/masterbrowser.php +++ b/web/plugins/masterbrowser/masterbrowser.php @@ -54,7 +54,7 @@ private function mustUpdateServerSummaryHtml() $this->db = new MasterServer(); $cacheInfo = new ContentInfo(); - $FrontController->contentCache()->getInfo(self::$serverSummaryCacheName, &$cacheInfo); + $FrontController->contentCache()->getInfo(self::$serverSummaryCacheName, $cacheInfo); return ($this->db->lastUpdate > $cacheInfo->modifiedTime); } diff --git a/web/plugins/pages/pages.php b/web/plugins/pages/pages.php index c94842aabd..81fcdcc541 100644 --- a/web/plugins/pages/pages.php +++ b/web/plugins/pages/pages.php @@ -45,7 +45,7 @@ public function mustUpdateCachedPage(&$pageFile, &$cacheName) if(!$FrontController->contentCache()->isPresent($cacheName)) return TRUE; $cacheInfo = new ContentInfo(); - $FrontController->contentCache()->getInfo($cacheName, &$cacheInfo); + $FrontController->contentCache()->getInfo($cacheName, $cacheInfo); return (filemtime($pageFile) > $cacheInfo->modifiedTime); }