From 29d4cc656f6e11333422e1d1808153bbb313a404 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Tue, 1 Dec 2015 12:43:32 +0000 Subject: [PATCH 1/2] MDL-52370 course: purge contacts cache on role rename Previously teachers would rename roles and the change would not be reflected in course listings. --- course/lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/course/lib.php b/course/lib.php index ba830ca0b15..851ed52a746 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2486,6 +2486,8 @@ function save_local_role_names($courseid, $data) { $rolename->name = $value; $DB->insert_record('role_names', $rolename); } + // This will ensure the course contacts cache is purged.. + coursecat::role_assignment_changed($roleid, $context); } } From 8f2c99d6102714ab760c336d6ef7651a4c914fdf Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Tue, 1 Dec 2015 13:12:34 +0000 Subject: [PATCH 2/2] MDL-52370 role: purge coursecontacts when role is edited This is perhaps a bit more brutal purge than you'd like, but it only affects coursecat role edits. --- admin/roles/classes/define_role_table_advanced.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/admin/roles/classes/define_role_table_advanced.php b/admin/roles/classes/define_role_table_advanced.php index 06f565d59a5..d18c144402d 100644 --- a/admin/roles/classes/define_role_table_advanced.php +++ b/admin/roles/classes/define_role_table_advanced.php @@ -422,6 +422,12 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi } else { // Updating role. $DB->update_record('role', $this->role); + + // This will ensure the course contacts cache is purged so name changes get updated in + // the UI. It would be better to do this only when we know that fields affected are + // updated. But thats getting into the weeds of the coursecat cache and role edits + // should not be that frequent, so here is the ugly brutal approach. + coursecat::role_assignment_changed($this->role->id, context_system::instance()); } // Assignable contexts.