simplified some code
This commit is contained in:
parent
84446fe0ec
commit
b514d767ef
@ -246,21 +246,12 @@ class Router implements RouterInterface
|
||||
protected function writeCacheFile($file, $content)
|
||||
{
|
||||
$tmpFile = tempnam(dirname($file), basename($file));
|
||||
if (!$fp = @fopen($tmpFile, 'wb')) {
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $tmpFile));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
chmod($file, 0644);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@fwrite($fp, $content);
|
||||
@fclose($fp);
|
||||
|
||||
if ($content != file_get_contents($tmpFile)) {
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s" (cache corrupted).', $tmpFile));
|
||||
}
|
||||
|
||||
if (!@rename($tmpFile, $file)) {
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
||||
}
|
||||
|
||||
chmod($file, 0644);
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
||||
}
|
||||
}
|
||||
|
@ -94,20 +94,12 @@ class ClassCollectionLoader
|
||||
static protected function writeCacheFile($file, $content)
|
||||
{
|
||||
$tmpFile = tempnam(dirname($file), basename($file));
|
||||
if (!$fp = @fopen($tmpFile, 'wb')) {
|
||||
die(sprintf('Failed to write cache file "%s".', $tmpFile));
|
||||
}
|
||||
@fwrite($fp, $content);
|
||||
@fclose($fp);
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
chmod($file, 0644);
|
||||
|
||||
if ($content != file_get_contents($tmpFile)) {
|
||||
die(sprintf('Failed to write cache file "%s" (cache corrupted).', $tmpFile));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!@rename($tmpFile, $file)) {
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
||||
}
|
||||
|
||||
chmod($file, 0644);
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
||||
}
|
||||
}
|
||||
|
@ -462,21 +462,13 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
||||
protected function writeCacheFile($file, $content)
|
||||
{
|
||||
$tmpFile = tempnam(dirname($file), basename($file));
|
||||
if (!$fp = @fopen($tmpFile, 'wb')) {
|
||||
die(sprintf('Failed to write cache file "%s".', $tmpFile));
|
||||
}
|
||||
@fwrite($fp, $content);
|
||||
@fclose($fp);
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
chmod($file, 0644);
|
||||
|
||||
if ($content != file_get_contents($tmpFile)) {
|
||||
die(sprintf('Failed to write cache file "%s" (cache corrupted).', $tmpFile));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!@rename($tmpFile, $file)) {
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
||||
}
|
||||
|
||||
chmod($file, 0644);
|
||||
throw new \RuntimeException(sprintf('Failed to write cache file "%s".', $file));
|
||||
}
|
||||
|
||||
public function serialize()
|
||||
|
Reference in New Issue
Block a user