diff --git a/lib/javascript.php b/lib/javascript.php index f8ad74c8dc9..7e7869fbac1 100644 --- a/lib/javascript.php +++ b/lib/javascript.php @@ -30,7 +30,6 @@ define('NO_DEBUG_DISPLAY', true); define('ABORT_AFTER_CONFIG', true); require('../config.php'); // this stops immediately at the beginning of lib/setup.php require_once("$CFG->dirroot/lib/jslib.php"); -require_once("$CFG->dirroot/lib/classes/minify.php"); if ($slashargument = min_get_slash_argument()) { $slashargument = ltrim($slashargument, '/'); @@ -93,6 +92,15 @@ if ($rev > 0 and $rev < (time() + 60*60)) { js_send_cached($candidate, $etag); } else { + // The JS needs minfifying, so we're gonna have to load our full Moodle + // environment to process it.. + define('ABORT_AFTER_CONFIG_CANCEL', true); + + define('NO_MOODLE_COOKIES', true); // Session not used here. + define('NO_UPGRADE_CHECK', true); // Ignore upgrade check. + + require("$CFG->dirroot/lib/setup.php"); + js_write_cache_file_content($candidate, core_minify::js_files($jsfiles)); // verify nothing failed in cache file creation clearstatcache();