mirror of
https://github.com/moodle/moodle.git
synced 2025-08-10 03:16:42 +02:00
MDL-41042 coursecat: better handle changes in coursecontact
This commit is contained in:
parent
ef176837dc
commit
0e0c8c0dd7
3 changed files with 4 additions and 10 deletions
|
@ -4802,6 +4802,8 @@ class admin_setting_special_coursecontact extends admin_setting_pickroles {
|
|||
parent::__construct('coursecontact', get_string('coursecontact', 'admin'),
|
||||
get_string('coursecontact_desc', 'admin'),
|
||||
array('editingteacher'));
|
||||
$this->set_updatedcallback(create_function('',
|
||||
"cache::make('core', 'coursecontacts')->purge();"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -708,16 +708,7 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
|
|||
}
|
||||
$managerroles = explode(',', $CFG->coursecontact);
|
||||
$cache = cache::make('core', 'coursecontacts');
|
||||
$cacheddata = $cache->get_many(array_merge(array('basic'), array_keys($courses)));
|
||||
// Check if cache was set for the current course contacts and it is not yet expired.
|
||||
if (empty($cacheddata['basic']) || $cacheddata['basic']['roles'] !== $CFG->coursecontact ||
|
||||
$cacheddata['basic']['lastreset'] < time() - self::CACHE_COURSE_CONTACTS_TTL) {
|
||||
// Reset cache.
|
||||
$keys = $DB->get_fieldset_select('course', 'id', '');
|
||||
$cache->delete_many($keys);
|
||||
$cache->set('basic', array('roles' => $CFG->coursecontact, 'lastreset' => time()));
|
||||
$cacheddata = $cache->get_many(array_merge(array('basic'), array_keys($courses)));
|
||||
}
|
||||
$cacheddata = $cache->get_many(array_keys($courses));
|
||||
$courseids = array();
|
||||
foreach (array_keys($courses) as $id) {
|
||||
if ($cacheddata[$id] !== false) {
|
||||
|
|
|
@ -179,6 +179,7 @@ $definitions = array(
|
|||
'mode' => cache_store::MODE_APPLICATION,
|
||||
'staticacceleration' => true,
|
||||
'simplekeys' => true,
|
||||
'ttl' => 3600,
|
||||
),
|
||||
// Used to store data for repositories to avoid repetitive DB queries within one request.
|
||||
'repositories' => array(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue