Skip to content

Commit

Permalink
#46 - applying correct chmod() to generated cache file
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Dec 18, 2014
1 parent 04fb8c2 commit e42f885
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 e42f885

Please sign in to comment.