mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 10:56:56 +02:00
Merge branch 'MDL-80985-add-purge-course-caches-option-main' of https://github.com/jwcatau/moodle
This commit is contained in:
commit
5c16854483
4 changed files with 204 additions and 1 deletions
|
@ -1191,7 +1191,7 @@ function purge_all_caches() {
|
|||
* 'other' Purge all other caches?
|
||||
*/
|
||||
function purge_caches($options = []) {
|
||||
$defaults = array_fill_keys(['muc', 'theme', 'lang', 'js', 'template', 'filter', 'other'], false);
|
||||
$defaults = array_fill_keys(['muc', 'courses', '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 {
|
||||
|
@ -1200,6 +1200,14 @@ function purge_caches($options = []) {
|
|||
if ($options['muc']) {
|
||||
cache_helper::purge_all();
|
||||
}
|
||||
if ($options['courses']) {
|
||||
if ($options['courses'] === true) {
|
||||
$courseids = [];
|
||||
} else {
|
||||
$courseids = preg_split('/\s*,\s*/', $options['courses'], -1, PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
course_modinfo::purge_course_caches($courseids);
|
||||
}
|
||||
if ($options['theme']) {
|
||||
theme_reset_all_caches();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue