MDL-67689 theme_boost: improve theme designer mode performance
authorBas Brands <bas@moodle.com>
Tue, 14 Jan 2020 10:28:55 +0000 (11:28 +0100)
committerBas Brands <bas@moodle.com>
Fri, 1 May 2020 06:26:50 +0000 (08:26 +0200)
lib/outputlib.php

index d50d022..e3a354e 100644 (file)
@@ -1208,6 +1208,7 @@ class theme_config {
      */
     public function get_css_content_debug($type, $subtype, $sheet) {
 
+
         if ($type === 'scss') {
             // The SCSS file of the theme is requested.
             $csscontent = $this->get_css_content_from_scss(true);
@@ -1430,9 +1431,17 @@ class theme_config {
 
         // TODO: MDL-62757 When changing anything in this method please do not forget to check
         // if the validate() method in class admin_setting_configthemepreset needs updating too.
-
+        $cacheoptions = '';
+        if ($themedesigner) {
+            $scsscachedir = $CFG->localcachedir . '/scsscache/';
+            $cacheoptions = array(
+                  'cacheDir' => $scsscachedir,
+                  'prefix' => 'scssphp_',
+                  'forceRefresh' => false,
+            );
+        }
         // Set-up the compiler.
-        $compiler = new core_scss();
+        $compiler = new core_scss($cacheoptions);
         $compiler->prepend_raw_scss($this->get_pre_scss_code());
         if (is_string($scss)) {
             $compiler->set_file($scss);