From 5d234a34ef6c0741eefdddbce1ba77da4d9a048e Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Wed, 25 Apr 2012 09:17:13 +0200 Subject: [PATCH] MDL-32612 prevent dir creation race condition notices in theme images --- theme/image.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/theme/image.php b/theme/image.php index 63acfaf0053..210b63ecca7 100644 --- a/theme/image.php +++ b/theme/image.php @@ -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);