"Fixes #3717, Temp files read/write errors under load"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6205 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-12-22 22:17:42 +00:00
parent b99ac8de46
commit 63a4e2e899

View file

@ -522,6 +522,7 @@ if (!function_exists('clone')) {
if ($write === false) {
return false;
} else {
@fclose($res);
return $write;
}
}
@ -558,25 +559,23 @@ if (!function_exists('clone')) {
$filename = TMP . $path;
break;
}
$timediff = $expires - $now;
$filetime = false;
if (file_exists($filename)) {
$filetime = @filemtime($filename);
}
if ($data === null) {
// Read data from file
if (file_exists($filename) && $filetime !== false) {
if ($filetime + $timediff < $now) {
// File has expired
@unlink($filename);
} else {
$data = file_get_contents($filename);
$data = @file_get_contents($filename);
}
}
} elseif (is_writable(dirname($filename))) {
file_put_contents($filename, $data);
@file_put_contents($filename, $data);
}
return $data;
}