diff --git a/lib/moodlelib.php b/lib/moodlelib.php index b5ea4586750..71ae951b076 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1437,8 +1437,6 @@ function purge_all_caches() { // hack: this script may get called after the purifier was initialised, // but we do not want to verify repeatedly this exists in each call make_cache_directory('htmlpurifier'); - - clearstatcache(); } /** @@ -9867,9 +9865,12 @@ function remove_dir($dir, $content_only=false) { } closedir($handle); if ($content_only) { + clearstatcache(); // make sure file stat cache is properly invalidated return $result; } - return rmdir($dir); // if anything left the result will be false, no need for && $result + $result = rmdir($dir); // if anything left the result will be false, no need for && $result + clearstatcache(); // make sure file stat cache is properly invalidated + return $result; } /** diff --git a/lib/setuplib.php b/lib/setuplib.php index 205cd3229e7..c206d10fb68 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -1077,6 +1077,10 @@ function redirect_if_major_upgrade_required() { * files outside of dataroot if you supply custom paths for some settings in config.php. * This function does not verify that the directory is writable. * + * NOTE: this function uses current file stat cache, + * please use clearstatcache() before this if you expect that the + * directories may have been removed recently from a different request. + * * @param string $dir absolute directory path * @param boolean $create directory if does not exist * @param boolean $recursive create directory recursively diff --git a/theme/image.php b/theme/image.php index a1a2e66b360..63acfaf0053 100644 --- a/theme/image.php +++ b/theme/image.php @@ -119,6 +119,9 @@ 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)); copy($imagefile, $cacheimage); } diff --git a/theme/javascript.php b/theme/javascript.php index afe5d013124..3ebba8bb191 100644 --- a/theme/javascript.php +++ b/theme/javascript.php @@ -81,6 +81,9 @@ require_once('Minify.php'); $theme = theme_config::load($themename); if ($rev > -1) { + // 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($candidate)); $fp = fopen($candidate, 'w'); fwrite($fp, minify($theme->javascript_files($type))); diff --git a/theme/styles.php b/theme/styles.php index 909bfb5468c..67385e3de09 100644 --- a/theme/styles.php +++ b/theme/styles.php @@ -117,6 +117,9 @@ send_cached_css($candidatesheet, $rev); function store_css(theme_config $theme, $csspath, $cssfiles) { $css = $theme->post_process(minify($cssfiles)); + // 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($csspath)); $fp = fopen($csspath, 'w'); fwrite($fp, $css);