mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-40563 fix race condition in debug styles when purging caches
This commit is contained in:
parent
ef201c966f
commit
2428de82b6
@ -22,6 +22,9 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// Disable moodle specific debug messages and any errors in output,
|
||||
// comment out when debugging or better look into error log!
|
||||
define('NO_DEBUG_DISPLAY', true);
|
||||
|
||||
define('ABORT_AFTER_CONFIG', true);
|
||||
require('../config.php'); // this stops immediately at the beginning of lib/setup.php
|
||||
@ -54,16 +57,22 @@ if ($usesvg) {
|
||||
$candidatesheet = "$CFG->cachedir/theme/$themename/designer_nosvg.ser";
|
||||
}
|
||||
|
||||
if (!file_exists($candidatesheet)) {
|
||||
|
||||
css_send_css_not_found();
|
||||
$css = false;
|
||||
if (is_readable($candidatesheet) and filemtime($candidatesheet) > time() - THEME_DESIGNER_CACHE_LIFETIME) {
|
||||
$css = @unserialize(file_get_contents($candidatesheet));
|
||||
}
|
||||
|
||||
if (!$css = file_get_contents($candidatesheet)) {
|
||||
css_send_css_not_found();
|
||||
}
|
||||
if (!is_array($css)) {
|
||||
// Ok, we need to start normal moodle script, we need to load all libs and $DB.
|
||||
define('ABORT_AFTER_CONFIG_CANCEL', true);
|
||||
|
||||
$css = unserialize($css);
|
||||
define('NO_MOODLE_COOKIES', true); // Session not used here.
|
||||
define('NO_UPGRADE_CHECK', true); // Ignore upgrade check.
|
||||
|
||||
require("$CFG->dirroot/lib/setup.php");
|
||||
$theme = theme_config::load($themename);
|
||||
$css = $theme->css_content();
|
||||
}
|
||||
|
||||
if ($type === 'editor') {
|
||||
if (isset($css['editor'])) {
|
||||
@ -112,4 +121,4 @@ if ($type === 'editor') {
|
||||
css_send_uncached_css($css['theme'][$sheet]);
|
||||
}
|
||||
}
|
||||
css_send_css_not_found();
|
||||
css_send_css_not_found();
|
||||
|
Loading…
x
Reference in New Issue
Block a user