Skip to content

Commit

Permalink
Homepage: Use a stream read in ContentCache::retrieve()
Browse files Browse the repository at this point in the history
Retrieving the contents of large files was generating warnings...
  • Loading branch information
danij-deng committed Mar 13, 2012
1 parent 235c3f6 commit bb2fe17
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions web/classes/contentcache.class.php
Expand Up @@ -93,18 +93,24 @@ public function isPresent($file)
* Attempt to retrieve a content element from the cache, copying
* its contents into a string.
*
* @param file (String) File name to retrieve.
* @param relPath (String) File name to retrieve.
* @return (Boolean) FALSE if the content element could not be
* found, else the content as a string.
*/
public function retrieve($file)
public function retrieve($relPath)
{
$file = FrontController::nativePath($this->_docRoot."/$file");
$path = FrontController::nativePath($this->_docRoot."/$relPath");

if(!file_exists($file))
throw new Exception(sprintf('file %s not present in content cache.', $file));
if(!file_exists($path))
throw new Exception(sprintf('file %s not present in content cache.', $relPath));

return file_get_contents($file);
if($stream = fopen($path, 'r'))
{
$contents = stream_get_contents($stream);
fclose($stream);
return $contents;
}
return "";
}

/**
Expand Down

0 comments on commit bb2fe17

Please sign in to comment.