Merge branch 'MDL-66367_master' of git://github.com/markn86/moodle
This commit is contained in:
@@ -50,6 +50,7 @@ class purge_caches extends \moodleform {
|
||||
$mform->createElement('advcheckbox', 'theme', '', get_string('purgethemecache', 'admin')),
|
||||
$mform->createElement('advcheckbox', 'lang', '', get_string('purgelangcache', 'admin')),
|
||||
$mform->createElement('advcheckbox', 'js', '', get_string('purgejscache', 'admin')),
|
||||
$mform->createElement('advcheckbox', 'template', '', get_string('purgetemplates', 'admin')),
|
||||
$mform->createElement('advcheckbox', 'filter', '', get_string('purgefiltercache', 'admin')),
|
||||
$mform->createElement('advcheckbox', 'muc', '', get_string('purgemuc', 'admin')),
|
||||
$mform->createElement('advcheckbox', 'other', '', get_string('purgeothercaches', 'admin'))
|
||||
|
||||
@@ -275,4 +275,10 @@ preferences,moodle|/user/preferences.php|t/preferences',
|
||||
$temp->add(new admin_setting_configtextarea('additionalhtmlfooter', new lang_string('additionalhtmlfooter', 'admin'), new lang_string('additionalhtmlfooter_desc', 'admin'), '', PARAM_RAW));
|
||||
$ADMIN->add('appearance', $temp);
|
||||
|
||||
$setting = new admin_setting_configcheckbox('cachetemplates', new lang_string('cachetemplates', 'admin'),
|
||||
new lang_string('cachetemplates_help', 'admin'), 1);
|
||||
$setting->set_updatedcallback('template_reset_all_caches');
|
||||
$temp = new admin_settingpage('templates', new lang_string('templates', 'admin'));
|
||||
$temp->add($setting);
|
||||
$ADMIN->add('appearance', $temp);
|
||||
} // end of speedup
|
||||
|
||||
@@ -654,6 +654,9 @@ $CFG->admin = 'admin';
|
||||
// Prevent JS caching
|
||||
// $CFG->cachejs = false; // NOT FOR PRODUCTION SERVERS!
|
||||
//
|
||||
// Prevent Template caching
|
||||
// $CFG->cachetemplates = false; // NOT FOR PRODUCTION SERVERS!
|
||||
//
|
||||
// Restrict which YUI logging statements are shown in the browser console.
|
||||
// For details see the upstream documentation:
|
||||
// http://yuilibrary.com/yui/docs/api/classes/config.html#property_logInclude
|
||||
|
||||
@@ -104,6 +104,8 @@ $string['bookmarkdeleted'] = 'Bookmark deleted.';
|
||||
$string['bookmarkthispage'] = 'Bookmark this page';
|
||||
$string['cachejs'] = 'Cache Javascript';
|
||||
$string['cachejs_help'] = 'Javascript caching and compression greatly improves page loading performance. it is strongly recommended for production sites. Developers will probably want to disable this feature.';
|
||||
$string['cachetemplates'] = 'Cache Templates';
|
||||
$string['cachetemplates_help'] = 'Template caching will improve page loading performance and is strongly recommended for production sites. Developers will probably want to disable this feature.';
|
||||
$string['calendarexportsalt'] = 'Calendar export salt';
|
||||
$string['calendarsettings'] = 'Calendar';
|
||||
$string['calendartype'] = 'Calendar type';
|
||||
@@ -1041,6 +1043,7 @@ $string['purgemuc'] = 'All MUC caches';
|
||||
$string['purgeothercaches'] = 'All file and miscellaneous caches';
|
||||
$string['purgeselectedcaches'] = 'Purge selected caches';
|
||||
$string['purgeselectedcachesfinished'] = 'The selected caches were purged.';
|
||||
$string['purgetemplates'] = 'Templates';
|
||||
$string['purgethemecache'] = 'Themes';
|
||||
$string['requestcategoryselection'] = 'Enable category selection';
|
||||
$string['restorecourse'] = 'Restore course';
|
||||
@@ -1264,6 +1267,7 @@ $string['taskstatscron'] = 'Background processing for statistics';
|
||||
$string['tasktagcron'] = 'Background processing for tags';
|
||||
$string['tasktempfilecleanup'] = 'Delete stale temp files';
|
||||
$string['tempdatafoldercleanup'] = 'Clean up temporary data files older than';
|
||||
$string['templates'] = 'Templates';
|
||||
$string['testoutgoingmailconf'] = 'Test outgoing mail configuration';
|
||||
$string['testoutgoingmaildetail'] = 'Note: Before testing, please save your configuration.<br />{$a}';
|
||||
$string['testoutgoingmailconf_message'] = 'This is a test message to confirm that you have successfully configured your site\'s outgoing mail.';
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -79,6 +79,11 @@ define([
|
||||
* @return {Object} jQuery promise resolved with the template source
|
||||
*/
|
||||
var getTemplatePromiseFromCache = function(searchKey) {
|
||||
// Do not cache anything if templaterev is not valid.
|
||||
if (M.cfg.templaterev <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// First try the cache of promises.
|
||||
if (searchKey in templatePromises) {
|
||||
return templatePromises[searchKey];
|
||||
@@ -92,7 +97,7 @@ define([
|
||||
}
|
||||
|
||||
// Now try local storage.
|
||||
var cached = storage.get('core_template/' + searchKey);
|
||||
var cached = storage.get('core_template/' + M.cfg.templaterev + ':' + searchKey);
|
||||
if (cached) {
|
||||
// Add this to the module cache for future.
|
||||
templateCache[searchKey] = cached;
|
||||
@@ -178,7 +183,7 @@ define([
|
||||
// Cache all of the dependent templates because we'll need them to render
|
||||
// the requested template.
|
||||
templateCache[tempSearchKey] = data.value;
|
||||
storage.set('core_template/' + tempSearchKey, data.value);
|
||||
storage.set('core_template/' + M.cfg.templaterev + ':' + tempSearchKey, data.value);
|
||||
|
||||
if (data.component == component && data.name == name) {
|
||||
// This is the original template that was requested so remember it to return.
|
||||
@@ -223,7 +228,7 @@ define([
|
||||
|
||||
if (requests.length) {
|
||||
// We have requests to send so resolve the deferred with the promises.
|
||||
serverRequestsDeferred.resolve(ajax.call(requests, true, false, false, 0, M.cfg.themerev));
|
||||
serverRequestsDeferred.resolve(ajax.call(requests, true, false, false, 0, M.cfg.templaterev));
|
||||
} else {
|
||||
// Nothing to load so we can resolve our deferred.
|
||||
serverRequestsDeferred.resolve();
|
||||
|
||||
+2
-1
@@ -284,9 +284,10 @@ function xmldb_main_install() {
|
||||
set_role_contextlevels($guestrole, get_default_contextlevels('guest'));
|
||||
set_role_contextlevels($userrole, get_default_contextlevels('user'));
|
||||
|
||||
// Init theme and JS revisions
|
||||
// Init theme, JS and template revisions.
|
||||
set_config('themerev', time());
|
||||
set_config('jsrev', time());
|
||||
set_config('templaterev', time());
|
||||
|
||||
// No admin setting for this any more, GD is now required, remove in Moodle 2.6.
|
||||
set_config('gdversion', 2);
|
||||
|
||||
+4
-1
@@ -1648,7 +1648,7 @@ function purge_all_caches() {
|
||||
* 'other' Purge all other caches?
|
||||
*/
|
||||
function purge_caches($options = []) {
|
||||
$defaults = array_fill_keys(['muc', 'theme', 'lang', 'js', 'filter', 'other'], false);
|
||||
$defaults = array_fill_keys(['muc', 'theme', 'lang', 'js', 'template', 'filter', 'other'], false);
|
||||
if (empty(array_filter($options))) {
|
||||
$options = array_fill_keys(array_keys($defaults), true); // Set all options to true.
|
||||
} else {
|
||||
@@ -1666,6 +1666,9 @@ function purge_caches($options = []) {
|
||||
if ($options['js']) {
|
||||
js_reset_all_caches();
|
||||
}
|
||||
if ($options['template']) {
|
||||
template_reset_all_caches();
|
||||
}
|
||||
if ($options['filter']) {
|
||||
reset_text_filters_cache();
|
||||
}
|
||||
|
||||
@@ -331,7 +331,8 @@ class page_requirements_manager {
|
||||
'svgicons' => $page->theme->use_svg_icons(),
|
||||
'usertimezone' => usertimezone(),
|
||||
'contextid' => $contextid,
|
||||
'langrev' => get_string_manager()->get_revision()
|
||||
'langrev' => get_string_manager()->get_revision(),
|
||||
'templaterev' => $this->get_templaterev()
|
||||
);
|
||||
if ($CFG->debugdeveloper) {
|
||||
$this->M_cfg['developerdebug'] = true;
|
||||
@@ -413,6 +414,25 @@ class page_requirements_manager {
|
||||
return $jsrev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the correct Template revision to use for this load.
|
||||
*
|
||||
* @return int the templaterev to use.
|
||||
*/
|
||||
protected function get_templaterev() {
|
||||
global $CFG;
|
||||
|
||||
if (empty($CFG->cachetemplates)) {
|
||||
$templaterev = -1;
|
||||
} else if (empty($CFG->templaterev)) {
|
||||
$templaterev = 1;
|
||||
} else {
|
||||
$templaterev = $CFG->templaterev;
|
||||
}
|
||||
|
||||
return $templaterev;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the specified JavaScript file is linked to from this page.
|
||||
*
|
||||
@@ -2104,6 +2124,23 @@ class YUI_config {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate all server and client side template caches.
|
||||
*/
|
||||
function template_reset_all_caches() {
|
||||
global $CFG;
|
||||
|
||||
$next = time();
|
||||
if (isset($CFG->templaterev) and $next <= $CFG->templaterev and $CFG->templaterev - $next < 60 * 60) {
|
||||
// This resolves problems when reset is requested repeatedly within 1s,
|
||||
// the < 1h condition prevents accidental switching to future dates
|
||||
// because we might not recover from it.
|
||||
$next = $CFG->templaterev + 1;
|
||||
}
|
||||
|
||||
set_config('templaterev', $next);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate all server and client side JS caches.
|
||||
*/
|
||||
|
||||
@@ -61,6 +61,9 @@ validation against and defaults to null (so, no user needed) if not provided.
|
||||
- add_screenshot
|
||||
- download_course_backup
|
||||
- upload_course_backup
|
||||
* A new setting 'Cache templates' was added (see MDL-66367). This setting determines if templates are cached or not.
|
||||
This setting can be set via the UI or by defining $CFG->cachetemplates in your config.php file. It is a boolean
|
||||
and should be set to either false or true. Developers will probably want to set this to false.
|
||||
|
||||
=== 3.7 ===
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2019083000.02; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2019083000.03; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user