MDL-32612 prevent dir creation race condition notices in theme images

This commit is contained in:
Petr Skoda
2012-04-28 17:14:38 +02:00
parent ee891dacc7
commit 5d234a34ef
+5 -4
View File
@@ -119,10 +119,11 @@ if ($rev > -1) {
$pathinfo = pathinfo($imagefile);
$cacheimage = "$candidatelocation/$image.".$pathinfo['extension'];
if (!file_exists($cacheimage)) {
// note: cache reset might have purged our cache dir structure,
// make sure we do not use stale file stat cache in the next check_dir_exists()
clearstatcache();
check_dir_exists(dirname($cacheimage));
if (!file_exists(dirname($cacheimage))) {
// Sometimes there was a race condition in check_dir_exists(),
// so let the next copy() log errors instead.
@mkdir(dirname($cacheimage), $CFG->directorypermissions, true);
}
copy($imagefile, $cacheimage);
}
send_cached_image($cacheimage, $rev);