mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-21208 major perf improvement for theme designer mode - now partially cached too ;-)
This commit is contained in:
parent
13ea159e9c
commit
7829cf7955
2 changed files with 38 additions and 21 deletions
|
@ -587,8 +587,29 @@ class theme_config {
|
|||
return array(new moodle_url($CFG->httpswwwroot.'/theme/styles.php', $params));
|
||||
|
||||
} else {
|
||||
// this is painfully slow, but it should not matter much ;-)
|
||||
$css = $this->css_content();
|
||||
// find out the current CSS and cache it now for 5 seconds
|
||||
// the point is to construct the CSS only once and pass it through the
|
||||
// dataroot to the script that actually serves the sheets
|
||||
$candidatesheet = "$CFG->dataroot/cache/theme/$this->name/designer.ser";
|
||||
if (!file_exists($candidatesheet)) {
|
||||
$css = $this->css_content();
|
||||
check_dir_exists(dirname($candidatesheet), true, true);
|
||||
file_put_contents($candidatesheet, serialize($css));
|
||||
|
||||
} else if (filemtime($candidatesheet) > time() - 5) {
|
||||
if ($css = file_get_contents($candidatesheet)) {
|
||||
$css = unserialize($css);
|
||||
} else {
|
||||
unlink($candidatesheet);
|
||||
$css = $this->css_content();
|
||||
}
|
||||
|
||||
} else {
|
||||
unlink($candidatesheet);
|
||||
$css = $this->css_content();
|
||||
file_put_contents($candidatesheet, serialize($css));
|
||||
}
|
||||
|
||||
$url = $CFG->httpswwwroot.'/theme/styles_debug.php';
|
||||
$urls = array();
|
||||
$urls[] = new moodle_url($url, array('theme'=>$this->name,'type'=>'yui2'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue