MDL-33293 use time() instead of counter for theme and JS revisions

This should help on sites that reset database, reinstall or switch databases.
This commit is contained in:
Petr Skoda
2012-05-23 11:11:13 +02:00
parent 56ff1300d9
commit f11db1a602
2 changed files with 20 additions and 4 deletions
+11 -3
View File
@@ -37,16 +37,24 @@ require_once($CFG->libdir.'/outputrequirementslib.php');
/**
* Invalidate all server and client side caches.
*
* This method deletes the phsyical directory that is used to cache the theme
* This method deletes the physical directory that is used to cache the theme
* files used for serving.
* Because it deletes the main theme cache directoy all themes are reset by
* Because it deletes the main theme cache directory all themes are reset by
* this function.
*/
function theme_reset_all_caches() {
global $CFG;
require_once("$CFG->libdir/filelib.php");
set_config('themerev', empty($CFG->themerev) ? 1 : $CFG->themerev+1);
$next = time();
if (isset($CFG->themerev) and $next <= $CFG->themerev and $CFG->themerev - $next < 60*60) {
// This resolves problems when reset is requested repeatedly within 1s,
// the < 1h condition prevents accidental switching to future dates
// because we might not recover from it.
$next = $CFG->themerev+1;
}
set_config('themerev', $next); // time is unique even when you reset/switch database
fulldelete("$CFG->cachedir/theme");
}
+9 -1
View File
@@ -1264,6 +1264,14 @@ function js_reset_all_caches() {
global $CFG;
require_once("$CFG->libdir/filelib.php");
set_config('jsrev', empty($CFG->jsrev) ? 1 : $CFG->jsrev+1);
$next = time();
if (isset($CFG->jsrev) and $next <= $CFG->jsrev and $CFG->jsrev - $next < 60*60) {
// This resolves problems when reset is requested repeatedly within 1s,
// the < 1h condition prevents accidental switching to future dates
// because we might not recover from it.
$next = $CFG->jsrev+1;
}
set_config('jsrev', $next);
fulldelete("$CFG->cachedir/js");
}