MDL-62767 theme: Remove old localcaches when clearing/updating theme cache

This commit is contained in:
Michael Hawkins
2018-07-03 14:00:51 +08:00
committed by Jun Pataleta
parent 032abb1a6f
commit d683aff069
2 changed files with 31 additions and 0 deletions
+7
View File
@@ -245,6 +245,7 @@ function theme_build_css_for_themes($themeconfigs = [], $directions = ['rtl', 'l
*/
function theme_reset_all_caches() {
global $CFG, $PAGE;
require_once("{$CFG->libdir}/filelib.php");
$next = theme_get_next_revision();
theme_set_revision($next);
@@ -257,6 +258,12 @@ function theme_reset_all_caches() {
// Purge compiled post processed css.
cache::make('core', 'postprocessedcss')->purge();
// Delete all old theme localcaches.
$themecachedirs = glob("{$CFG->localcachedir}/theme/*", GLOB_ONLYDIR);
foreach ($themecachedirs as $localcachedir) {
fulldelete($localcachedir);
}
if ($PAGE) {
$PAGE->reload_theme();
}