Skip to content

Commit

Permalink
MDL-32612 prevent dir creation race condition notices in theme images
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Apr 28, 2012
1 parent ee891da commit 5d234a3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions theme/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@
$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);
Expand Down

0 comments on commit 5d234a3

Please sign in to comment.