Created
March 17, 2020 23:10
-
-
Save timhunt/f969f46f60756197f320e03ed0d27a36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/minify/matthiasmullie-minify/src/Minify.php b/lib/minify/matthiasmullie-minify/src/Minify.php | |
index e5fefe6f948..e0511a76a59 100644 | |
--- a/lib/minify/matthiasmullie-minify/src/Minify.php | |
+++ b/lib/minify/matthiasmullie-minify/src/Minify.php | |
@@ -39,6 +39,7 @@ abstract class Minify | |
*/ | |
protected $patterns = array(); | |
+ protected $times = []; | |
/** | |
* This array will hold content of strings and regular expressions that have | |
* been extracted from the JS source code, so we can reliably match "code", | |
@@ -115,7 +116,14 @@ abstract class Minify | |
$this->save($content, $path); | |
} | |
- return $content; | |
+ $timing = "/*\n"; | |
+ foreach ($this->times as $i => $info) { | |
+ $timing .= $info['calls'] . ' calls, ' . $info['time'] . " seconds\n"; | |
+ $timing .= $this->patterns[$i][0] . "\n"; | |
+ $timing .= "-------------------------\n"; | |
+ } | |
+ $timing .= "*/\n"; | |
+ return $timing . $content; | |
} | |
/** | |
@@ -252,6 +260,8 @@ abstract class Minify | |
} | |
$match = null; | |
+ | |
+ $timestart = microtime(true); | |
if (preg_match($pattern, $content, $match, PREG_OFFSET_CAPTURE)) { | |
$matches[$i] = $match; | |
@@ -265,6 +275,12 @@ abstract class Minify | |
// ignore this one until we reach end of content | |
unset($matches[$i], $positions[$i]); | |
} | |
+ $timetaken = microtime(true) - $timestart; | |
+ if (!isset($this->times[$i])) { | |
+ $this->times[$i] = ['calls' => 0, 'time' => 0]; | |
+ } | |
+ $this->times[$i]['calls'] += 1; | |
+ $this->times[$i]['time'] += $timetaken; | |
} | |
// no more matches to find: everything's been processed, break out | |
diff --git a/theme/styles.php b/theme/styles.php | |
index 2b25d142401..60b728a2a56 100644 | |
--- a/theme/styles.php | |
+++ b/theme/styles.php | |
@@ -108,7 +108,7 @@ $theme->set_rtl_mode($type === 'all-rtl' ? true : false); | |
$themerev = theme_get_revision(); | |
$currentthemesubrev = theme_get_sub_revision_for_theme($themename); | |
-$cache = true; | |
+$cache = false; | |
// If the client is requesting a revision that doesn't match both | |
// the global theme revision and the theme specific revision then | |
// tell the browser not to cache this style sheet because it's | |
@@ -158,7 +158,7 @@ if (($fallbacksheet = theme_styles_fallback_content($theme)) && !$theme->has_css | |
// Use a realistic lock timeout as the intention is to avoid lock contention. | |
$locktimeout = rand(90, 120); | |
} | |
- | |
+$sendaftergeneration = true; | |
// Attempt to fetch the lock. | |
$lockfactory = \core\lock\lock_config::get_lock_factory('core_theme_get_css_content'); | |
$lock = $lockfactory->get_lock($themename, $locktimeout); | |
@@ -201,7 +201,7 @@ function theme_styles_generate_and_store($theme, $rev, $themesubrev, $candidated | |
require_once("{$CFG->libdir}/filelib.php"); | |
// Generate the content first. | |
- if (!$csscontent = $theme->get_css_cached_content()) { | |
+ if (true || !$csscontent = $theme->get_css_cached_content()) { | |
$csscontent = $theme->get_css_content(); | |
$theme->set_css_content_cache($csscontent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment