Skip to content

Commit

Permalink
Merge pull request #49 from Ocramius/hotfix/#46-file-cache-reader-per…
Browse files Browse the repository at this point in the history
…missions

#46 - applying correct `chmod()` to generated cache file
  • Loading branch information
Ocramius committed Dec 20, 2014
2 parents 04fb8c2 + e42f885 commit 433906a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Doctrine/Common/Annotations/FileCacheReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,13 @@ private function saveCacheFile($path, $data)
}

$tempfile = tempnam($this->dir, uniqid('', true));

if (false === $tempfile) {
throw new \RuntimeException(sprintf('Unable to create tempfile in directory: %s', $this->dir));
}

$written = file_put_contents($tempfile, '<?php return unserialize('.var_export(serialize($data), true).');');

if (false === $written) {
throw new \RuntimeException(sprintf('Unable to write cached file to: %s', $tempfile));
}
Expand All @@ -208,6 +210,7 @@ private function saveCacheFile($path, $data)
throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
}

@chmod($path, 0666 & ~umask());
@unlink($tempfile);
}

Expand Down

0 comments on commit 433906a

Please sign in to comment.