From 592ea4b97588a0e3ed51a8d4f49b5180e8a83a61 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Fri, 19 Jun 2015 17:07:59 +0800 Subject: [PATCH] MDL-50645 cache: get_plugins_with_function for more than one plugintype --- lib/moodlelib.php | 8 +++++--- user/classes/output/myprofile/manager.php | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 07a1800686f..0153f48ec09 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -4841,10 +4841,12 @@ function remove_course_contents($courseid, $showfeedback = true, array $options // Cleanup the rest of plugins. $cleanuplugintypes = array('report', 'coursereport', 'format'); + $callbacks = get_plugins_with_function('delete_course', 'lib.php'); foreach ($cleanuplugintypes as $type) { - $plugins = get_plugin_list_with_function($type, 'delete_course', 'lib.php'); - foreach ($plugins as $plugin => $pluginfunction) { - $pluginfunction($course->id, $showfeedback); + if (!empty($callbacks[$type])) { + foreach ($callbacks[$type] as $pluginfunction) { + $pluginfunction($course->id, $showfeedback); + } } if ($showfeedback) { echo $OUTPUT->notification($strdeleted.get_string('type_'.$type.'_plural', 'plugin'), 'notifysuccess'); diff --git a/user/classes/output/myprofile/manager.php b/user/classes/output/myprofile/manager.php index 05837e8765f..d3064250344 100644 --- a/user/classes/output/myprofile/manager.php +++ b/user/classes/output/myprofile/manager.php @@ -69,13 +69,13 @@ class manager { } // Plugins. - $types = \core_component::get_plugin_types(); - foreach ($types as $type => $dir) { - $pluginlist = get_plugin_list_with_function($type, "myprofile_navigation", "lib.php"); - foreach ($pluginlist as $function) { + $pluginswithfunction = get_plugins_with_function('myprofile_navigation', 'lib.php'); + foreach ($pluginswithfunction as $plugins) { + foreach ($plugins as $function) { $function($tree, $user, $iscurrentuser, $course); } } + $tree->sort_categories(); return $tree; }